Kaseya Community

Shell command (windows) xcopy command

This question is not answered

Hey guys and girls,

I am trying to copy a file from a path to a certain directory, the old directory was "C:\Program Files\Soduct" the new should be "C:\Program Files (x86)\Soduct" Now the procedure still succeeds but the file is not copied, this is because of the (x86) in the directory path.

Anyone knows how to solve this problem? Would be appriciated :)



<?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="Soduct Update Win2k8" treePres="3" id="1300764177">
<Body description="">
<Statement description="Execute the given command as if it were typed in at a command prompt." name="ExecuteShellCommand" continueOnFail="false" osType="NT4|2000|XP|2003|Vista|2008">
<Parameter xsi:type="StringParameter" name="Command" value="tskill soduct /a /v" />
<Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="System" />
<Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />
</Statement>
<Statement description="Pause this procedure for N seconds to give a previous action time to complete." name="PauseScript" continueOnFail="false" osType="NT4|2000|XP|2003|Vista|2008">
<Parameter xsi:type="IntegerParameter" name="Seconds" value="5" />
</Statement>
<Statement description="Attempts to return results of a shell command to a global variable '#global:cmdresults#'" name="Execute Shell Command - Get Results to Variable" continueOnFail="false" osType="NT4|2000|XP|2003|Vista|2008">
<Parameter xsi:type="StringParameter" name="Parameter1" value="xcopy &quot;\\jsdfil01\Data\Productie\SODUCTdatabase\Last update\Soduct.exe&quot; &quot;C:\Program Files (x86)\Soduct&quot; /D" />
<Parameter xsi:type="StringParameter" name="Parameter2" value="false" />
<Parameter xsi:type="StringParameter" name="Parameter3" value="System" />
</Statement>
<Statement description="Pause this procedure for N seconds to give a previous action time to complete." name="PauseScript" continueOnFail="false" osType="NT4|2000|XP|2003|Vista|2008">
<Parameter xsi:type="IntegerParameter" name="Seconds" value="5" />
</Statement>
<If description="">
<Condition name="CheckVariable">
<Parameter xsi:type="StringParameter" name="VariableName" value="#global:cmdresults#" />
<Parameter xsi:type="EnumParameter" name="Condition" value="Equals" />
<Parameter xsi:type="StringParameter" name="Value" value="1 File(s) copied" />
</Condition>
<Then>
<Statement description="Send an email from the server (address specified in the Configure function in the System module)." name="SendEmail" continueOnFail="false" osType="NT4|2000|XP|2003|Vista|2008">
<Parameter xsi:type="StringParameter" name="To" value="helpdesk@" />
<Parameter xsi:type="StringParameter" name="Subject" value="Soduct update procedure on &lt;id&gt;" />
<Parameter xsi:type="StringParameter" name="Body" value="Soduct has succeeded on &lt;id&gt;!" />
</Statement>
<If description="">
<Condition name="CheckVariable">
<Parameter xsi:type="StringParameter" name="VariableName" value="#global:cmdresults#" />
<Parameter xsi:type="EnumParameter" name="Condition" value="Equals" />
<Parameter xsi:type="StringParameter" name="Value" value="0 File(s) copied" />
</Condition>
<Then>
<Statement description="Send an email from the server (address specified in the Configure function in the System module)." name="SendEmail" continueOnFail="false" osType="NT4|2000|XP|2003|Vista|2008">
<Parameter xsi:type="StringParameter" name="To" value="helpdesk@" />
<Parameter xsi:type="StringParameter" name="Subject" value="Soduct update procedure on &lt;id&gt;" />
<Parameter xsi:type="StringParameter" name="Body" value="Soduct update on &lt;id&gt; not needed or failed!" />
</Statement>
</Then>
</If>
</Then>
</If>
</Body>
</Procedure>
</ScriptExport>

All Replies
  • can you try the sys variable  %ProgramFiles(x86)%

    take out the quotes

    Also your using a command shell - are you using system account as I can see your trying to copy from a network share but if you are using system it will most likely not have access to a network share... We normally use a impersonate user if we are doing this, but can't see without importing script if you are using system.

  • mmartin,

    I now inserted a impersonated user, still it is not working. The credentials from the agent is a domain admin so this should be ok when the procedure is running and getting the file from the share. I already tested this by doing the same command in a agent procedure but changing the the destination to C:\TMP and this just copies the executable fine. I am sure it has a issue with the following path C:\Program Files (x86)\data\ i have changed it to %ProgramFiles(x86)%\data and it is still not working.

  • Hi Jack just a side note

    the agent credentials have nothing to do with running the script unless you use the 'Use Credentials' option sorry not impersonate user although this acts the same  - if you choose system it runs it as the local system account irrespective of what credentials you used for the agent under the agent menu.  By default unless something has been changed a local 'system' account would not have rights to a network share, obviously system account is fine for most things on the local machine.

    i just did a quick test there and ran this command  - I used an execute shell command.

    xcopy "\\tt-fp-01\data\Managed Service\msprocessflow.vsd" "c:\program files (x86)\Winscp" /d

    When i did it the script ran fine but no file - I then added the impersonate user and put in some network credentials and then changed the execute shell command to use logged on user and it worked fine.