Kaseya Community

Scripts that use Shell (batch files)

  • I wrote a small batch file that allows me to copy ONCE a week the servers Image createds by Kaseya/Acronis on a NAS Station to a 500 GB USB drive. The Script just checks for presence of the USB Drive, cleans-up any old directories and files and copies the images.

    The batch file on the Server when launched from a command prompt works fine all the time but when launched using the "execute Shell Command" with Kaseya script, everything works fine EXCEPT writing the files to the directories. I am testing it with 2K files for now and no matter what I tried, the writing (Xcopy or Copy) never takes place. Again, if I remote accessing ther Server that has the USB Drive attached to and dropped to a command line, all works beautifully.
    Any ideas?

    Gerard Louise

    Legacy Forum Name: Scripts that use Shell (batch files),
    Legacy Posted By Username: glouise
  • What is the path that the batch file is executing from in the script? In other words is it frnning from C:\temp?

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: boudj
  • boudj
    What is the path that the batch file is executing from in the script? In other words is it frnning from C:\temp?


    The scripts runs on the Remote Server and is using c:\scripts (all bat files reside there!)

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: glouise
  • Try renaming the file with a .cmd extension. I've had good luck with that when batch files fail.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: sequoya
  • sequoya
    Try renaming the file with a .cmd extension. I've had good luck with that when batch files fail.


    Or create the batch file on the server, rather than have a "downloaded" copy of the batch file. This could be an 'untrusted source' issues.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: Anthony Michaud
  • Anthony Michaud
    Or create the batch file on the server, rather than have a "downloaded" copy of the batch file. This could be an 'untrusted source' issues.


    That seems strange - if that's true, then any executable sent to the client by the KServer should be marked as such. Have you seen this happen before?

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: sequoya
  • If you provide the code for the batch file, we may be able to help you troubleshoot this problem.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: RCS-Michael
  • Make sure you are very aware of relative vs. actual paths in what you are doing. For the most part, the batch files execute from the windows directory. If you have any relative paths in your batch file make sure you have "cd"'ed to the proper location first.
    I found that surprise after a few hours of cursing at one point. Also, be very aware that if your script fails (i.e. chucks out an errorlevel failure), kaseya scripts will not see this as a problem and will continue and indicate that the script ran successfully.
    We have a work around for this, but it's not pretty.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: rhayes@expertnetsolutions.com