9 Replies Latest reply on Jul 31, 2008 9:39 AM by Jared Barneck

    Deploying a script or a batch file from the console - Help

    Rookie

       

      Hello,

       

       

      I have a very simple batch file.bat  "XCOPY C:\MyFiles\*.* z:\MyFiles\ /s /i /d /y"

       

       

      that I'd like  to run at 4 PM every day. 

       

       

      I would like to schedule a task to execute the script on my workstations.

       

       

      As anyone done this before? Can you direct me? Thank you All, JRene 

       

       

        • 1. Re: Deploying a script or a batch file from the console - Help
          zman Master
          1. Create the batch file

          2. Place it on a distribution share

          3. Create a distribution package - Batch File

          4. Create Policy Supported Push Deliver Method to your liking.

          5. Create a Scheduled Task - Select Distro package and PSP Deliver Method.

          6. Select Schedule Task in the left hand pane

          7. Select Start Later

          8. Select 4pm for the time

          9. Select Repeat Every Day.

           

          Could also do it with a local scheduled task, but this should be a little easier.

          • 2. Re: Deploying a script or a batch file from the console - Help
            Rookie

             

            Thank you for the quick response.

             

             

            I haven't tried yet but I will keep you posted.

             

             

            Thanks again, Jrene

             

             

            • 3. Re: Deploying a script or a batch file from the console - Help
              Rookie

               

              Hi Zman,

               

               

              Cool name by the way.

               

               

              OK! my task failed on every machine! Failing message is "the system cannot open the file"

               

               

              I put the batch file in a shore folder and followed your instruction.

               

               

              Any idea!

               

               

              Thank you, Jrene

               

               

              • 4. Re: Deploying a script or a batch file from the console - Help
                zman Master

                Without logfiles I would guess that z: is a network share that the localsystem account (context that the job is running under) does not have access to. Sorry did not see this earlier.  So assuming that the users have rights to both folders (target and destination) then change your distribution package (exe in lieu of batch) to:

                 

                 

                 

                startasuser.exe ///silent  \\batch file location\batchfile.cmd
                

                 

                 

                 

                Running Commands as the Logged on User Using StartAsUser.exe

                 

                 

                 

                Also I would pick one or two machines as a test    Also some older LANDesk versions do not have startasuser < 8.61 . If no user is logged onto the system when the startasuser.exe application is launched the application will return the standard Windows ERROR_NOT_LOGGED_ON (1245) error. You can also add authentication to the share in the batch file ....NET USE....but I would not do this becuase of security concerns.

                • 5. Re: Deploying a script or a batch file from the console - Help
                  Jared Barneck SupportEmployee

                  Actually you "Z:" drive does not exist as Local System, so StartAsUser.exe will allow the package to run as a user but that will not exactly solve your problem...because what if a user is not logged in.

                   

                  The correct answer should be this:

                   

                  1. Place the batch file on the share that Z: is mapped to:

                   


                  myserver\myshare\some\folder\some\batchfile.bat

                   

                  2. Create a UNC-based Distribution Package (YES it has to be UNC-based)

                   

                  3. Configured Preferred Package Server so there is authentication to the
                  myserver shares.

                   

                  4. Create a "Run from source" delivery method. Yes it has to be "Run from source".

                   

                  5. Change the batch file to use the
                  myserver\myshare\ instead of the Z: drive.  For example, z:\MyFiles\ becomes
                  myserver\myshare\myfiles\

                   

                  6. Make sure the batch file is not in SDMCache (machines you have been testing to must have it deleted).

                   

                  Now guess what happens...the Preferred Package server settings authenticate to the share and because it is run from source, the batch file runs from that share and authentication should remain to that share as long as the batch file is running.

                   

                  If you use download from source, the batch file is downloaded and run from the client so you will not maintain authentication to the share.

                  • 6. Re: Deploying a script or a batch file from the console - Help
                    zman Master

                    Jared,

                     

                     

                     

                     

                     

                    Good stuff!  I was under the impression (actually seen it in writing) that preferred server credentials is only used to grab the package for download.   So if you have run from source, it uses the preferred server authentication for the entire job - is this correct?  If so that would be nice  and a great tip!  I was aware of the user not logged in and had that as part of my prior post as a warning.

                     

                     

                     

                     

                     

                    I wish we could have a user credential that was configurable that the entire process is run under run from source and not run from source.

                    • 7. Re: Deploying a script or a batch file from the console - Help
                      Jared Barneck SupportEmployee

                      I just got the tip myself from David Eatough...I can't take credit, it has to go to him.

                      • 8. Re: Deploying a script or a batch file from the console - Help
                        Rookie

                         

                        Hello Rhyous and thank you for the directions

                         

                         

                        I tried to implement your direction and I am getting the following

                         

                         

                        "Cleint does not support batch file packages"

                         

                         

                        I am not sure I correctly implemented the preferred server package to authenticate to the server share.

                         

                         

                        I have a share directory on a server

                         

                         


                        server\User_data\%username%

                         

                         

                        I put the batch file under
                        server\user_data\

                         

                         

                        and under
                        server\User_data\%username%

                         

                         

                         

                         

                        to be sure that it was in the right place...but I was no succesful..

                         

                         

                        Could you direct me? Thank you

                         

                         

                        Jrene

                         

                         

                         

                         

                         

                         

                         

                         

                         

                         

                         

                        • 9. Re: Deploying a script or a batch file from the console - Help
                          Jared Barneck SupportEmployee

                          "Cleint does not support batch file packages"

                           

                          That is a completely different error altogether.  That means your client is having an inventory problem and we cannot tell what version of the agent is on the client.