Kaseya Community

Script failing on testfile

This question is not answered

Hi All,

i've wrote a fairly basic procedure but apparent it's failing on "testfile".

can someone tell me what im doing wrong?

    <If description="">
        <Condition name="TestFile">
          <Parameter xsi:type="StringParameter" name="Path" value="C:\kworking\sfcresults.txt" />
          <Parameter xsi:type="EnumParameter" name="Condition" value="Exists" />
          <Parameter xsi:type="StringParameter" name="Value" value="" />
        </Condition>
        <Then>
          <Statement name="ExecuteShellCommand" continueOnFail="true">
            <Parameter xsi:type="StringParameter" name="Command" value="del C:\kworking\sfcresults.txt" />
            <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="System" />
            <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />
          </Statement>
        </Then>
        <Else>
          <Statement name="ExecuteShellCommand" continueOnFail="false">
            <Parameter xsi:type="StringParameter" name="Command" value="sfc /scannow &gt; C:\kworking\sfcresults.txt" />
            <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="System" />
            <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />
          </Statement>
          <Statement name="GetVariable" continueOnFail="false">
            <Parameter xsi:type="EnumParameter" name="VariableType" value="FileContent" />
            <Parameter xsi:type="StringParameter" name="SourceContent" value="C:\kworking\sfcresults.txt" />
            <Parameter xsi:type="StringParameter" name="VariableName" value="sfcresultscontent" />
          </Statement>
          <Statement name="SendEmail" continueOnFail="false">
            <Parameter xsi:type="StringParameter" name="To" value="#emailaddress#" />
            <Parameter xsi:type="StringParameter" name="Subject" value="SFC Results for #vAgentConfiguration.agentGuid#" />
            <Parameter xsi:type="MultiLineStringParameter" name="Body" value="#sfcresultscontent#" />
          </Statement>

All Replies
  • I recommend two things:

    1 - Posting a screenshot of the failed step within your agent procedures log

    2 - Joining our discord community for more active interaction with our users:

    https://discord.gg/3kM9AC

  • You're hard-coding the C:\KWorking path - this is not a good idea. There are times where an agent may already exist when the "real" one is installed, and the working directory is dynamically renamed to KWorking1, KWorking2, etc.

    The best way is to define a KWorking variable via getVariable("Agent Working Directory Path,", " ", "KWorking", "All windows...") and reference your file as #KWorking#\sfcresults.txt. This will always reference the KWorking folder from the perspective of that agent's relationship with your VSA.

    Glenn