1 2 Previous Next 23 Replies Latest reply on Jan 7, 2008 10:00 AM by puercomal

    Batch File Deployment

    Rookie

       

      Hi,

       

      I am currently in the process of making changes to multiple machines via a batch file which i need to roll out via LANDesk.

       

      The batch file is pushed out to the machines fine and is stored in the cache folder on the client machine and the success message returned is "Done, Requires Reboot".

       

      The problem is, the batch file is never actually run on the client machine even though LANDesk states it was succesful. Even after a reboot, no changes are made to the PC by the batch file. I am using a custom push deployment method that ignores bandwidth restrictions and rolls out to 200 machines at a time.

       

      The batch file is simple and is as follows...

       

      @echo off

                     cls

       

       

                     REM Remove 8i Path Variables and add Oracle 9i Path variable

                     U:\Uniform7\clients\ORA9XP\reg.exe @U:\Uniform7\clients\ORA9XP\local.ri

       

       

                     REM Insert 9i registry entries

                     %SystemRoot%\regedit /s U:\Uniform7\clients\ORA9XP\regfiles\ORAODBC.reg

       

       

                     REM Create Temp folder for Uniform

                     md c:\uniform

                     md c:\uniform\temp

       

       

                     REM Pauses the batch process by 2 seconds

                     PING 123.123.123.123 -n 2 -w %1000 >NUL

       

       

                     exit

       

      Any help you can provide me would be great.

       

       

      Thanks,

      Reiss.

       

       

        • 1. Re: Batch File Deployment
          phoffmann SupportEmployee

          The most common problems is usually related to LOCAL SYSTEM permissions in one way or another.

           

          What do the SDCLIENT-logs say - do they actually say that they've tried to run the commands? If they do, then LANDesk has tried to run them.

           

          Since I will assume that your users do NOT have local admin rights, SDCLIENT automatically elevates itself into LOCAL SYSTEM context, and tries to run things like that. Make sure first of all that your batch will work in that context.

           

          As long as you can have LANDesk execute a simple batch-file (such as containing only a call to "notepad.exe"), it should work (or at least - try to execute) anything you throw at it. Usually the thing that'll skew things is the user-context.

           

          Here's what you need to do:

           

          ##########

          1. Open a command prompt > CMD

          2. Run the 'at' command with the following syntax: "at hh:mm /interactive cmd "

           

          i.e.:

          ""

          at 15:46 /interactive cmd

          ""

           

          will launch a CMD-box at 15:46 local time on your PC

           

          3. At the time in the command a new command prompt window will open. This window is running as local system.

          ##########

           

          And that way, you can make sure that this is the problem you're running into. We usually use the above procedure to check NT-permissions on UNC shares, but it's useful for all sorts of other things when you need/want to test out whether an install (or whatever) works with LOCAL SYSTEM rights :).

           

          This will give you a good "line-by-line" debug capacity to find out where you're falling flat on your nose, I'd hope.

           

          Added complications come in the form of "Are those drives mapped automatically? Can we access them at all? What about if no one is logged in?" - so there's a fair few factors.

           

          Hope that this will get you in the right direction :).

           

          Paul Hoffmann

          LANDesk EMEA Technical Lead.

          • 2. Re: Batch File Deployment
            Rookie

            Hi Paul,

             

            Thanks for the reply.

             

            I have tried what you suggested and the batch file didnt run at all. No error message though.

             

            Does this mean the batch file is incompatible running as the local service user?

            • 3. Re: Batch File Deployment
              Rookie

               

              Here is the log file from the SDClient.

               

               

              Thu, 03 Jan 2008 14:09:24 Checking preferred server path
              tc.local\root\dsl\uniform\Uniform Spatial 7.4\Packages\Windows XP\Environment Variables - XP.cmd instead of
              tc.local\root\dsl\uniform\Uniform Spatial 7.4\Packages\Windows XP\Environment Variables - XP.cmd

                             Thu, 03 Jan 2008 14:09:24 Path
              tc.local\root\dsl\uniform\Uniform Spatial 7.4\Packages\Windows XP\Environment Variables - XP.cmd was redirected to
              tc.local\root\dsl\uniform\Uniform Spatial 7.4\Packages\Windows XP\Environment Variables - XP.cmd

                             Thu, 03 Jan 2008 14:09:24 File (
              tc.local\root\dsl\uniform\Uniform Spatial 7.4\Packages\Windows XP\Environment Variables - XP.cmd) is not in cache

                             Thu, 03 Jan 2008 14:09:24 Checking preferred server path
              tc.local\root\dsl\uniform\Uniform Spatial 7.4\Packages\Windows XP\Environment Variables - XP.cmd instead of
              tc.local\root\dsl\uniform\Uniform Spatial 7.4\Packages\Windows XP\Environment Variables - XP.cmd

                             Thu, 03 Jan 2008 14:09:24 Path
              tc.local\root\dsl\uniform\Uniform Spatial 7.4\Packages\Windows XP\Environment Variables - XP.cmd was redirected to
              tc.local\root\dsl\uniform\Uniform Spatial 7.4\Packages\Windows XP\Environment Variables - XP.cmd

                             Thu, 03 Jan 2008 14:09:24 WM_CREATE

                             Thu, 03 Jan 2008 14:09:24 WM_STARTCLIENT

                             Thu, 03 Jan 2008 14:09:26 Downloading file 1 of 1 from '
              tc.local\root\dsl\uniform\Uniform Spatial 7.4\Packages\Windows XP\Environment Variables - XP.cmd'

                             Thu, 03 Jan 2008 14:09:26 Checking preferred server path
              tc.local\root\dsl\uniform\Uniform Spatial 7.4\Packages\Windows XP\Environment Variables - XP.cmd instead of
              tc.local\root\dsl\uniform\Uniform Spatial 7.4\Packages\Windows XP\Environment Variables - XP.cmd

                             Thu, 03 Jan 2008 14:09:26 Path
              tc.local\root\dsl\uniform\Uniform Spatial 7.4\Packages\Windows XP\Environment Variables - XP.cmd was redirected to
              tc.local\root\dsl\uniform\Uniform Spatial 7.4\Packages\Windows XP\Environment Variables - XP.cmd

                             Thu, 03 Jan 2008 14:09:28 WinNT

                             Thu, 03 Jan 2008 14:09:28 Batch file Client Thread

                             Thu, 03 Jan 2008 14:09:28 PackagePath:  http:// \\ tc.local\root\dsl\uniform\Uniform Spatial 7.4\Packages\Windows XP\Environment Variables - XP.cmd

                             Thu, 03 Jan 2008 14:09:28 Checking recently used server path
              tc.local\root\dsl\uniform\Uniform Spatial 7.4\Packages\Windows XP\Environment Variables - XP.cmd instead of
              tc.local\root\dsl\uniform\Uniform Spatial 7.4\Packages\Windows XP\Environment Variables - XP.cmd

                             Thu, 03 Jan 2008 14:09:28 Path
              tc.local\root\dsl\uniform\Uniform Spatial 7.4\Packages\Windows XP\Environment Variables - XP.cmd was redirected to
              tc.local\root\dsl\uniform\Uniform Spatial 7.4\Packages\Windows XP\Environment Variables - XP.cmd

                             Thu, 03 Jan 2008 14:09:30 Installation result 1

                             Thu, 03 Jan 2008 14:09:30 processing of package is complete, result 1 (0x00000001 - code 1)

               

               

              • 4. Re: Batch File Deployment
                phoffmann SupportEmployee

                Heh - beware, there's several locations for log-files.

                 

                Log-files for software distribution (client-side) can be found in two places:

                 

                • C:\Program Files\LANDesk\LDClient\

                ==> SDCLIENT.LOG

                 

                • C:\Program Files\LANDesk\LDClient\Data\

                => SDCLIENT.LOG

                => SDCLIENT_TASK##.log

                 

                Particularly the SDCLIENT_TASK##.log (where ## == the number/TASK_IDN of the task in the database's "LD_TASK" table) is useful and will tell you usually the things you want to know most :).

                 

                #########

                 

                Now, if running your batch-file as Local System doesn't give you anything - then yes - you will have problems with your Batchfile itself. LANDesk only tries to execute the commands, it doesn't ensure they actually ran or got anwywhere, as it were.

                 

                My suggestion, keep using the LOCAL SYSTEM command-line box and - rather than running the entire batch-file - run one command at a time.

                 

                See if you can get the commands to execute - my guess is that not - and at least this way you'll have a frame of a single command (at a time) that you can fiddle with to get it to work.

                 

                Potentially, you might be better off using an AUTOIT script (see http://www.autoitscript.com/autoit3/ ), but that purely depends on personal preference (AutoIT "scripts" can be compiled into executables) - since the problem seems to be more one of permissions (or utter lack thereof) as far as the LOCAL SYSTEM account is concerned :(.

                 

                Paul Hoffmann

                LANDesk EMEA Technical Lead

                • 5. Re: Batch File Deployment
                  phoffmann SupportEmployee

                  Addendum:

                   

                  If I were to hazard a guess, your first problem is going to be with the network-drive mapping - the U:\ drive may be mapped for a user, but not for the local system account - you might want to use full UNC-paths instead.

                   

                  Again - test those using the command-box first - as you might have to change some policies on a 2003 Box for instance (adding the "Domain Computers" account may not be sufficient in the case of 2003 - it can be rather contrary towards UNC-access) .

                  • 6. Re: Batch File Deployment
                    Rookie

                     

                    Hi Paul,

                     

                     

                    I have came to the same conclusion that the Local System account does not have access to the U:\ Drive Mapping.

                     

                     

                    Although it would work, unfortunately i am unable to use full UNC paths due to the fact that if we rename the server at any point, that will mean we have 400 machines we will need to make changes too.

                     

                     

                    Thanks for your help, you have given me an idea of where to look to try and resolve this.

                     

                     

                    • 7. Re: Batch File Deployment
                      phoffmann SupportEmployee

                      Happy to be of help.

                       

                      The AutoIT scripts have helped various folks (including myself) to pull similar stunts off (since it's a VERY flexible tool, as you'll find out quickly).

                       

                      Alternatively, you can "cheat", and put the files you want on an HTTP share, and simply use SDCLIENT /F to copy them down.

                       

                      Paul Hoffmann

                      LANDesk EMEA Technical Lead.

                      • 8. Re: Batch File Deployment
                        phoffmann SupportEmployee

                        Additional Addendum.

                         

                        You COULD just specify those files as "additional files" for the Batch-package, potentially ...?

                         

                        (talk about missing the obvious) - that way you can get them easily enough through an internal HTTP share as well .

                        • 9. Re: Batch File Deployment
                          Rookie

                           

                          The problem here is that its not actually copying any files across to the client machines.

                           

                           

                          This batch file is adding lines to the PATH in the Environment Variables of the machines.

                           

                           

                          • 10. Re: Batch File Deployment
                            phoffmann SupportEmployee

                            Ah OK - yes, for that I do believe you will have to trick your way into "full on" administrator rights, regrettably .

                            • 11. Re: Batch File Deployment
                              Rookie

                               

                              I have decided to try and eliminate certain possibilities by trying this with a full UNC path as a test before going ahead of changing the permissions on the LANDesk Admin Account.

                               

                               

                              Ill post my findings either later today or tomorrow.

                               

                               

                              • 12. Re: Batch File Deployment
                                Jared Barneck SupportEmployee

                                I see a couple problems.

                                 

                                1.  You end with the EXIT command.  That is not correct.  If you read about the EXIT command, you will see that it causes the batch file and the process that launched the batch file to close immediately.  We need the process that launched the batch file to stay open. 

                                 

                                Instead use this:  Exit /B 

                                 

                                For more information just run EXIT /? from a command prompt.

                                 

                                2. You are trying to use drives that were mapped by a user while running as local system.

                                 

                                If you want to use REG.EXE just add it as an additional file to the batch file distribution package (an any dependent files it may need to run but if it is just Microsoft's REG.EXE I don't think it has dependencies).  If you want to run REG.EXE against U:\Uniform7\clients\ORA9XP\reg.exe @U:\Uniform7\clients\ORA9XP\local.ri, you should also add local.ri as an additional file to the batch file.  Place them all in the same directory as the batch file and you don't even need paths.

                                 

                                You also should add the .reg file as an additional file and also copy landesk's LDSleep.exe to the same share as the batch file and add it as an additional file too.

                                 

                                So your distribution package would have the batch file as the primary file.  Three files as additonal files and should look like this:

                                 

                                REM Batch files are always silent when deploy by LANDesk
                                REM but ECHO to a log file on the client if ECHO is ON.
                                REM Always leave ECHO on so you can see it in the log.
                                 
                                REM Remove 8i Path Variables and add Oracle 9i Path variable
                                reg.exe local.ri 
                                 
                                REM Insert 9i registry entries
                                regedit /s ORAODBC.reg 
                                 
                                REM Create Temp folder for Uniform
                                md c:\uniform
                                md c:\uniform\temp 
                                 
                                REM Pauses the batch process by 2 seconds
                                REM Use ldsleep.exe for this, so you don't cause excessive network traffic
                                LDSleep.exe 2 
                                 
                                exit /B
                                

                                 

                                 

                                However, what if your batch file fails when running  reg.exe local.ri?  How will you know.

                                 

                                You need to read this whitepaper I wrote to help you out:

                                http://community.landesk.com/support/docs/DOC-2320

                                • 13. Re: Batch File Deployment
                                  Jared Barneck SupportEmployee

                                   

                                  Don't try to access the UNC path in the batch file.  Making Local System have access to a share can be a permissions nightmare, or it can be as easy as adding "Domain Computers" group to the share and NTFS permissions.  It depends on your settings.

                                   

                                   

                                  Just add the files as additional files to the distribution package and let them be downloaded to the client and run from there.

                                   

                                   

                                  If you have to use UNC, then you have to. But it is easier not to try to use UNC from batch file running as Local System.

                                   

                                   

                                  • 14. Re: Batch File Deployment
                                    Rookie

                                     

                                    Hi,

                                     

                                     

                                    For the above batch file to run, then surely i will need the additional files in the same folder as the batch file thats being run?

                                     

                                     

                                     

                                     

                                     

                                    1 2 Previous Next