/build/static/layout/Breadcrumb_cap_w.png

Running a Batch File

I am trying to create a K1000 Script to run a batch file. The batch file is just to xcopy 2 files from a network share to the %USERPROFILE%/Appdata/Roaming/SAP/Common folder. I have uploaded the .bat file and the two files that I want to copy in the dependencies. What else do I need to set in the Tasks in order for this script to run properly?

My bat looks like this, if correct..?

xcopy /s /Y "\\servername\folder1\SAP GUI 740\NWSAPADMIN\CustomerFiles" "%USERPROFILE%\APPDATA\Roaming\SAP\Common"

1 Comment   [ + ] Show comment
  • I have a FileSync that I use instead of a regular script. If you're merely copying files from one location to another, perhaps that's all you need.

    That said, my FileSync is conditional in that it first checks to ensure that the files I am copying are not already present.

    Also, when I am deploying files and a bat script, I package everything together in an archive, set all my actions and conditions in the bat file, and then my script merely calls the bat file.

    When Kace deploys my archive, it autoextracts it on my target. Then the bat file takes care of everything else. - rskwire 7 years ago

Answers (1)

Posted by: Nico_K 7 years ago
Red Belt
2
Keep a few things in mind:
1. by default the K1000 agent runs scripts as system service. So if you try to do this, it will fail.
2. you can run scripts as logged in user (which would be a good idea in that case) but need to verify that this user has the correct rights
3. if the files are static you should zip them and roll out via the KACE (add it as dependency to the script and unzip it), so you don't need to verify that other servers need to be online and the user has the correct rights etc

Comments:
  • Ok, so I have run the script under my admin credentials and uploaded the zip file as a dependency.

    My task is set to On Success: Unzip file

    Path is set to the destination folder of the .ZIP

    File: name of the .ZIP

    Target: %USERPROFILE%\Appdata\Roaming\SAP\Common - Midnite8 7 years ago
    • yes, and this will only copy the files for the admin user. If you want that the currently logged in user is pointed, use run as logged in user.
      Hopefully you used as path
      $(KACE_DEPENDENCY_DIR) (which is the variable for the local kbots, it is easier than checking this manually, all variables can be found by clicking on the question mark next to the tasks) - Nico_K 7 years ago
      • The script ran successfully but I still do not see the 2 files copied into the path I put in. I am running it under Run as Logged in User
        Output Log

        Running as: SYSTEM
        Directory DOES exist: C:\ProgramData\Dell\KACE\kbots_cache\packages\kbots\290
        Activity Log

        Checking if directory exists: C:\ProgramData\Dell\KACE\kbots_cache\packages\kbots\290
        Unzipping file: \\liv-it\E\SAP GUI 740 Packages\CustomerFiles.zip C:\Windows\system32\config\systemprofile\Appdata\Roaming\SAP\Common
        Started: 02/16/2017 15:35:20
        Finished: 02/16/2017 15:35:20
        Elapsed Time: 0 seconds
        Status: 1
        Output Log

        Running as SYSTEM
        Directory DOES exist: C:\ProgramData\Dell\KACE\kbots_cache\packages\kbots\290
        Activity Log

        Checking if directory exists: C:\ProgramData\Dell\KACE\kbots_cache\packages\kbots\290
        Unzipping file: \\liv-it\E\SAP GUI 740 Packages\CustomerFiles.zip C:\Windows\system32\config\systemprofile\Appdata\Roaming\SAP\Common - Midnite8 7 years ago

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ