Kaseya Community

Script to run a Batch file

  • I have a simple script that copies a batch file to the temp folder and then runs the batch file. My procedure copies the file over fine but won’t run the batch file. Can someone help?

    This is the script

    <?xml version="1.0" encoding="utf-8" ?>

    - <ScriptExport xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.kaseya.com/vsa/2008/12/Scripting">

    - <Procedure name="Add Printers" treePres="3" id="1273449587">

    - <Body description="">

    - <Statement description="Execute the given command as if it were typed in at a command prompt." name="ExecuteShellCommand" continueOnFail="false" osType="Windows">

      <Parameter xsi:type="StringParameter" name="Command" value="copy \\stp-support\shortcuts\printers.bat C:\Temp\" />

      <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="System" />

      <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />

      </Statement>

    - <Statement description="Execute the given command as if it were typed in at a command prompt." name="ExecuteShellCommand" continueOnFail="false" osType="Windows">

      <Parameter xsi:type="StringParameter" name="Command" value="C:\Temp\printers.bat" />

      <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="System" />

      <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />

      </Statement>

      </Body>

      </Procedure>

      </ScriptExport>

     

     

     

     

  • Can you run c:\temp\printers.bat from a live connect command prompt?

  • From live connect command prompt the batch file runs but doesn’t load the printers. From the command prompt on the PC the batch file runs and loads the printers like it should.

    This is the batch file

    Rem  Load Printers

    @echo off

    Start \\stp-print4\smg3dxrx1

    Start \\stp-print4\ctcxrx3

    start \\stp-print3\orxrx2

  • Rather than run it as System tell the script to impersonate a user or wait for a user to login. Local System wont have permissions to access the network devices.