Kaseya Community

Script to copy KAV installation files to agent

  • We are experiencing a wide range of problems migrating from "Classic" to new KAV.    One thing we noticed is that the new installer seems to erase the KAV directory after a failed install, eliminating some of our abilities to troubleshoot.

    We are getting the following error on a SaaS server (Ticket 145453):

    Procedure Log:

    10:22:11 am 20-Jul-16 KAV: Install KAV Failed THEN in step 13

    10:22:11 am 20-Jul-16 KAV: Install KAV FAILED in processing THEN step 13, Write File, with error File or Directory Not Found, Source = D:\Kaseya\WebPages\ManagedFiles\VSAHiddenFiles\kav\Installers\10.2.4.674\Kes10win.msi, Destination = c:\kworking\KAV\Kes10win.msi


    To help troubleshoot, I was thinking of trying to download the files manually and see if it would run, or even try to manually install.    Does anyone have a script that will copy all the install files down?

    Just don't want to re-invent the wheel.  Thanks!

  • In certain situations, transferring the setup files to the working directory does solve error 13 issues.  We've seen a few instances in which KAV installation files can't or won't get pushed to endpoints but for some reason it doesn't affect files transferred from procedures.

    Here's the official KB on how to do it:  helpdesk.kaseya.com/.../34261116-How-do-I-Pre-Deploy-the-KAV-installer-package-to-endpoints

    I personally found that process to be a bit cumbersome though.  What we ended up doing was this:

    • installing KAV on a workstation,
    • copying the entire install directory of that good workstation intall to the KServer's ManagedFiles directory
    • creating a very simple writeDirectory script that copied the contents of that ManagedFiles directory to the client's working directory
    • Running the KAV install as normal.

    We periodically update those install files as new KAV versions get released.  It works pretty well for those handful of machines that just refuse to cooperate.



    formatting?
    [edited by: mcconnell at 8:09 AM (GMT -7) on Jul 25, 2016]
  • , Thanks for the update.   in this case the files would have to be uploaded to SaaS server (which is in the UK), so I don't think it will make much difference.  Pulling files from SaaS seems to be throttled.  I went ahead and zipped all the install files and put them out on the web, and wrote a script to download and un-zip them.   We will see if that works any better!

  • I hit a similar problem with downloading from a Saas server and used the GetURL command as a workaround. This allowed us to put the file on a webserver with much higher bandwidth. The same method may be of use for you..

  • , yep exactly what I did.  If anyone is interested in doing this, here is the script (less the URL code).  (WHY is there no "CODE" formatting option!)

    [ code ]

    <?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="KAV - 10.2.4 Manual Download" treePres="3" id="1429934302" folderId="21521792588116713137229117" treeFullPath="myProcedures - VAAdmin">
        <Body description="KAV 10.2.4 - Manual Download.  Downloads the installation files from web to Kworking\KAV directory.&#xA;&#xA;(c) 2016 - Virtual Administrator (Network Depot, LLC) ALL Rights Reserved">
          <Statement name="GetVariable" continueOnFail="false">
            <Parameter xsi:type="EnumParameter" name="VariableType" value="AgentTempDirectory" />
            <Parameter xsi:type="StringParameter" name="SourceContent" value="" />
            <Parameter xsi:type="StringParameter" name="VariableName" value="agentTempDir" />
          </Statement>
          <Statement name="WriteScriptLogEntry" continueOnFail="false">
            <Parameter xsi:type="StringParameter" name="Comment" value="Downloading file to #agentTempDir#" />
          </Statement>
          <Statement description="Check for KAV directory" name="Execute Shell Command - Get Results to Variable" continueOnFail="false">
            <Parameter xsi:type="StringParameter" name="Parameter1" value="dir #agentTempDir#\KAV" />
            <Parameter xsi:type="StringParameter" name="Parameter2" value="True" />
            <Parameter xsi:type="StringParameter" name="Parameter3" value="System" />
          </Statement>
          <If description="If not found, create directory">
            <Condition name="CheckVariable">
              <Parameter xsi:type="StringParameter" name="VariableName" value="#global:cmdresults#" />
              <Parameter xsi:type="EnumParameter" name="Condition" value="Contains" />
              <Parameter xsi:type="StringParameter" name="Value" value="File not Found" />
            </Condition>
            <Then>
              <Statement name="ExecuteShellCommand" continueOnFail="false">
                <Parameter xsi:type="StringParameter" name="Command" value="md #agentTempDir#\KAV" />
                <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="System" />
                <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="True" />
              </Statement>
            </Then>
          </If>
          <If description="Check for Install ZIP file and re-use or download if not there">
            <Condition name="TestFile">
              <Parameter xsi:type="StringParameter" name="Path" value="#agentTempDir#\KAV\KAVinstaller.zip" />
              <Parameter xsi:type="EnumParameter" name="Condition" value="NotExists" />
              <Parameter xsi:type="StringParameter" name="Value" value="" />
            </Condition>
            <Then>
              <Statement name="WriteScriptLogEntry" continueOnFail="false">
                <Parameter xsi:type="StringParameter" name="Comment" value="Zip file not found, Downloading" />
              </Statement>
              <Statement name="GetURL" continueOnFail="false">
                <Parameter xsi:type="StringParameter" name="URL" value="put your URL location and file here" />
                <Parameter xsi:type="StringParameter" name="ResponseFileName" value="#agentTempDir#\KAV\KAVinstaller.zip" />
                <Parameter xsi:type="BooleanParameter" name="WaitComplete" value="True" />
              </Statement>
            </Then>
            <Else>
              <Statement name="WriteScriptLogEntry" continueOnFail="false">
                <Parameter xsi:type="StringParameter" name="Comment" value="Zip file already there, using that instead of re-downloading" />
              </Statement>
            </Else>
          </If>
          <If description="Check to make sure Installer zip downloaded successfully">
            <Condition name="TestFile">
              <Parameter xsi:type="StringParameter" name="Path" value="#agentTempDir#\KAV\KAVinstaller.zip" />
              <Parameter xsi:type="EnumParameter" name="Condition" value="Exists" />
              <Parameter xsi:type="StringParameter" name="Value" value="" />
            </Condition>
            <Then>
              <Statement name="WriteScriptLogEntry" continueOnFail="false">
                <Parameter xsi:type="StringParameter" name="Comment" value="Zip File found, un-zipping" />
              </Statement>
              <Statement name="Unzip file" continueOnFail="false">
                <Parameter xsi:type="StringParameter" name="Parameter1" value="#agentTempDir#\KAV\KAVinstaller.zip" />
                <Parameter xsi:type="StringParameter" name="Parameter2" value="#agentTempDir#\KAV\" />
                <Parameter xsi:type="StringParameter" name="Parameter3" value="True" />
              </Statement>
              <If description="Check to make sure un-zip went well">
                <Condition name="TestFile">
                  <Parameter xsi:type="StringParameter" name="Path" value="#agentTempDir#\KAV\setup.exe" />
                  <Parameter xsi:type="EnumParameter" name="Condition" value="Exists" />
                  <Parameter xsi:type="StringParameter" name="Value" value="" />
                </Condition>
                <Then>
                  <Statement name="WriteScriptLogEntry" continueOnFail="false">
                    <Parameter xsi:type="StringParameter" name="Comment" value="Files were successfully un-zipped" />
                  </Statement>
                  <Statement name="DeleteFile" continueOnFail="false" osType="None">
                    <Parameter xsi:type="StringParameter" name="Path" value="#agentTempDir#\KAV\KAVinstaller.zip" />
                  </Statement>
                </Then>
                <Else>
                  <Statement name="WriteScriptLogEntry" continueOnFail="false">
                    <Parameter xsi:type="StringParameter" name="Comment" value="FAIL - Files did not un-zip correctly" />
                  </Statement>
                </Else>
              </If>
            </Then>
            <Else>
              <Statement name="WriteScriptLogEntry" continueOnFail="false">
                <Parameter xsi:type="StringParameter" name="Comment" value="Download failed,  zip file not found" />
              </Statement>
            </Else>
          </If>
        </Body>
      </Procedure>
    </ScriptExport>
    [ /code ]