Kaseya Community

Script Write file issue

  • ​I am attempting to get a script to write a file. Originally it was a more elaborate script, but once it started to fail on the Write File portion, I created a new script that did nothing else but write a file. It has failed against 4 servers every time it has been run. The file is a simple batch file. he 4 servers are:

    Server 2008 R2 Standard, No AV
    Server 2008 Standard, KES
    Server 2003 R2, KES
    Server SBS 2003, KES

    This is a simple script that has nothing but the write file line. I have changed it to include the Use Credential and Impersonate User, but none of the variations work.

    I have entered and tested the credential.

    Cannot figure out why this is not working.

  • Post the script so we can take a look.

    Take a peek at the script log on the agent and the ACL of the destination folder. Usually permissions aren't a problem, but something screwy might be going on there.

    Make sure the file doesn't exist already (and is currently in use).

  • Also where does it write the file to and does the file already exist or does your script make the file?

    Best place to create meta and log files is under the Agent Temp Dir. The Agent Temp Dir is a good place to work in because you already know that the agent has the correct permission level to write to it.

  • Here is the script:

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

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

     <Procedure name="Bill's Test" treePres="3">

       <Body description="">

         <Statement description="Write the selected file to the machine at the path specified - full path required." name="WriteFile" continueOnFail="false">

           <Parameter xsi:type="StringParameter" name="Path" value="#vAgentConfiguration.agentTempDir#" />

           <Parameter xsi:type="StringParameter" name="ManagedFile" value="VSASharedFiles\PsExec.exe" />

         </Statement>

       </Body>

     </Procedure>

    </ScriptExport>

    It writes to the ="#vAgentConfiguration.agentTempDir#"  which is the agent working directory.

    All permissions on the folder are good. The credential is a domain admin/Local Admin.

  • The path needs to include a file name. For example:

    #vAgentConfiguration.agentTempDir#\PsExec.exe

  • That did the trick.