10 Replies Latest reply on Jan 24, 2014 1:07 PM by MikeM

    Batch File Issue




      I have a simple bat file that contains just two lines:


      MOVE "C:\WINDOWS\System32\i386\Applications\Microsoft Office" "C:\Microsoft Office"

      "C:\Microsoft Office\Setup.exe" /config "C:\Microsoft Office\Standard.WW\config.xml"


      As you can see - the install files already exist on the machine, but they're buried to where End Users won't find them nor have access.

      Bat file simply moves the files to the root of C and then runs the silent install....I tested the batch file and it works as it's supposed to.

      LANDesk is not executing the BAT file - it copies it down to "sdmcache - PKG- etc." but does not execute


      It's for WIN 7 ( UAC if off)

      LANDesk Mgmt Suite 9 SP3



        • 1. Re: Batch File Issue
          MrGadget Expert

          When running a bat file through Landesk it doesn't always react the same as just being on the machine and running the bat file.


          I going to guess either C:\Microsoft Office does not exist and it can't move it there without the folder already existing or it doesn't know if in the first line c:\windows\system32\i386\applications\microsoft office is a file or folder.

          • 2. Re: Batch File Issue

            "It doesn't always"?? So sometimes it does and other times it doesn't? That doesn't seem ideal at all ...


            You're correct "C:\Microsoft Office" folder doesn't exist  - Why would I have to create the folder when the MOVE command is simply relocating it; seems redundant to create said folder...call the bat file to move the MS office folder to the location of the created MS office folder??


            I actually just created a VBS just to test a different methodology...This time just simply creating a VBS that simply moves the folder from its currently location to its new at C root. The VBS works fine and does this as I tested it before having LANDesk deploy it - But when I ask LANDesk deploy it - It comes back as SUCCESSFUL but it actually didn't complete the task.

            • 3. Re: Batch File Issue
              MrGadget Expert

              Download PSEXEC.exe if you don't already have it. Put it in your root dir. bring up a command prompt, change to root dir and type in psexec -i -s cmd.exe  This brings up another command window that runs under the system account. Then change to dir where the batch file is and type it in,  exp John.bat.

              I ran the first line of your batch file in this way and it said cannot find the file specified.

              • 4. Re: Batch File Issue

                Sorry MrGadget I guess I wasn't clear on a few things - The folder "C:WINDOWS\System32\i386\Applications\Microsoft Office" is always present on our machines =]   It's where we keep files in case something may need to be re-installed on our image. So yes it's not going to be on your machine, but it's on all the ones we deploy.

                • 5. Re: Batch File Issue
                  Frank Wils ITSMMVPGroup

                  Are you on a x64 OS? Than don't forget in your defined Software Distribution Package in the Console to check the 'Run as 64-bit on 64-bit OS's' checkbox option. Than save, close and re-schedule the deployment or rightclick on your package and choose Reset Package Hash.



                  • 6. Re: Batch File Issue
                    MarXtar ITSMMVPGroup

                    'Doesn't always' really means that because the batch file runs as local system rather than a standard user, behaviours can be different to what is expected. Also, because the interface is suppressed, a message popping up may not be noticed.


                    You say the batch file isn't being executed. Can we go a little fursther on that if Frank's suggestion doesn't do the trick?


                    When you send this with LANDesk, what is the result of the task?

                    What is you have the batch file start with a 'dir > output.txt' command? Do you see the contents of the directory written to the text file?


                    I'd like to know if the batch is launched at all or if it is an issue with your commands.


                    Also, a nice easy way to launch a command prompt as local system without another tool like PSEXEC is to use LANDesk Remote Control and the Remote Execute function to launch CMD.EXE. Providing you have a remote control setting that allows 'Run as Administrator' then it has the same effect.


                    In there, change directory to the location of the downloaded batch file and run it to see what messages you get for each command line.


                    Mark McGinn

                    MarXtar Ltd/MarXtar Corporation


                    LANDesk Expert Solution Provider



                    The One-Stop Shop for LANDesk Enhancements

                    - Wake-On-WAN - Distributed Wake-On-LAN, Scheduled Power Down, and SWDist Sequencing

                    - State Notifier - Real-Time Device & User State Inventory Updating & Alerting

                    Update - New Stand-Alone State Notifier Console for Service Desk Operators

                    Update - State Notifier now detects machine and user Idle states

                    Update - WoW & State Notifier now integrate for even more functionality

                    • 7. Re: Batch File Issue

                      Ok so I got the file moving after re-writing my Vbs...now when I push it out - It performs the first part of it, moving the file, but doesn't perform the last line of running:


                      'on error resume next

                      Set objFSO=CreateObject("Scripting.FileSystemObject")

                      objFSO.MoveFolder "C:\WINDOWS\System32\i386\Applications\Microsoft Office","C:\WINDOWS\System32\i386\Applications\MicrosoftOffice"

                      objFSO.MoveFolder "C:\WINDOWS\System32\i386\Applications\MicrosoftOffice","C:\MicrosoftOffice"

                      wscript.sleep (5000)

                      Dim objShell

                      Set objShell = WScript.CreateObject ("WScript.shell")

                      objShell.run "cmd /c C:\MicrosoftOffice\Setup.exe /config C:\MicrosoftOffice\Standard.WW\Config.xml"


                      We've tested this and it works flawlessly on the system...but LANDesk doesn't want to perform the last part...and it comes back as successful after using the PUSH distribution method....


                      Thoughts? And thanks again!

                      • 8. Re: Batch File Issue
                        marcel Specialist

                        In my opinion LANDesk runs vbs Scripts in cscript environment, so wscript objects dont work.


                        In my environment i only use AutoIT for distribution, because here you have many many many functions for Software packaging und distribution.


                        Here is your script in AutoIT:


                        dirmove("C:\WINDOWS\System32\i386\Applications\Microsoft Office","C:\WINDOWS\System32\i386\Applications\MicrosoftOffice")







                        $error = RunWait("C:\MicrosoftOffice\Setup.exe /config C:\MicrosoftOffice\Standard.WW\Config.xml","C:\MicrosoftOffice\",@SW_HIDE)



                        exit $error



                        With this Script you get also an errorlevel to your LANDesk Console



                        • 9. Re: Batch File Issue



                          Using AutoIT do you comple it as an exe and then use LANDesk to build the package as an exe? Or are you still building it as a Windows Script Host package?



                          • 10. Re: Batch File Issue
                            MikeM Employee

                            You would compile the script to an EXE and distribute it as an executable package.