Kaseya Community

Error running batch file - No mapping between user accounts...

  • I tried posting this in the Agent forum and haven't gotten a reply - perhaps this is a better section for my problem? Sorry for the duplicate post, I really need help on this...

    This is an issue that cropped up for me with the new 6.3 update. I'm trying to run a batch file that creates the Scheduled Task to allow CCleaner to run without UAC:

    schtasks /CREATE /TN CCleanerSkipUAC /TR "c:\rcs\cc\CCleaner.exe $(Arg0)" /SC ONCE /ST 12:00 /RL HIGHEST /F

    I can run the batch file just fine manually, but when I run as system (and redirect errors to a text file) with an agent procedure I get this error:

    ERROR: No mapping between account names and security IDs was done.
    (16,8):UserId:
  • I don't bother with any of that garbage. Just disable UAC on the fly....

    <?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="Clean Temp Files - ccleaner.exe" treePres="3" id="115226332" folderId="54171652521616924127116991" treeFullPath="Common Scripts.System Maintenance.Disk Cleanup">

       <Body description="Cleans Temp Files using ccleaner.exe.&#xA;&#xA;- system temp&#xA;- user temp&#xA;- browser cache&#xA;- error reports&#xA;- start-run history&#xA;&#xA;Works for currently logged-in user only. Will fail if user not logged in.&#xA;&#xA;Bypasses UAC prompt in Vista/7/2008 OS's.&#xA;&#xA;Safe for servers and workstations.&#xA;">

         <If description="">

           <Condition name="UserIsLoggedIn">

             <Parameter xsi:type="StringParameter" name="UserName" value="" />

           </Condition>

           <Then>

             <Statement description="Create a named procedure variable and assign a value retrieved from the managed machine by the agent." name="GetVariable" continueOnFail="true">

               <Parameter xsi:type="EnumParameter" name="VariableType" value="RegistryValue" />

               <Parameter xsi:type="StringParameter" name="SourceContent" value="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\ConsentPromptBehaviorAdmin" />

               <Parameter xsi:type="StringParameter" name="VariableName" value="UACValue" />

             </Statement>

             <If description="">

               <Condition name="Windows 32 or 64 Bit Check">

                 <Parameter xsi:type="EnumParameter" name="Condition" value="NotExists" />

               </Condition>

               <Then>

                 <Statement description="Set the specified registry value - Regedit displays keys as folders and values as documents." name="SetRegistryValue" continueOnFail="false">

                   <Parameter xsi:type="StringParameter" name="RegistryPath" value="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\ConsentPromptBehaviorAdmin" />

                   <Parameter xsi:type="StringParameter" name="Value" value="0" />

                   <Parameter xsi:type="EnumParameter" name="DataType" value="Integer" />

                 </Statement>

                 <Statement description="Write the selected directory, subdirectories and files to the machine at the path specified." name="WriteDirectory" continueOnFail="false">

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

                   <Parameter xsi:type="StringParameter" name="SourceDirectory" value="VSASharedFiles\ccleaner\" />

                   <Parameter xsi:type="StringParameter" name="Param3" value="" />

                 </Statement>

                 <Statement description="Execute the specified file - full path to file required." name="ExecuteFile" continueOnFail="false">

                   <Parameter xsi:type="StringParameter" name="Path" value="#vAgentConfiguration.AgentTempDir#\ccleaner\ccleaner.exe" />

                   <Parameter xsi:type="StringParameter" name="Arguments" value="/AUTO" />

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

                   <Parameter xsi:type="BooleanParameter" name="WaitComplete" value="True" />

                 </Statement>

                 <If description="">

                   <Condition name="CheckVariable">

                     <Parameter xsi:type="StringParameter" name="VariableName" value="#UACValue#" />

                     <Parameter xsi:type="EnumParameter" name="Condition" value="Exists" />

                     <Parameter xsi:type="StringParameter" name="Value" value="" />

                   </Condition>

                   <Then>

                     <Statement description="Set the specified registry value - Regedit displays keys as folders and values as documents." name="SetRegistryValue" continueOnFail="false">

                       <Parameter xsi:type="StringParameter" name="RegistryPath" value="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\ConsentPromptBehaviorAdmin" />

                       <Parameter xsi:type="StringParameter" name="Value" value="#UACValue#" />

                       <Parameter xsi:type="EnumParameter" name="DataType" value="Integer" />

                     </Statement>

                   </Then>

                 </If>

                 <Statement description="Write an Entry into the Procedure Log" name="WriteScriptLogEntry" continueOnFail="false">

                   <Parameter xsi:type="StringParameter" name="Comment" value="ccleaner completed" />

                 </Statement>

               </Then>

               <Else>

                 <Statement description="Set the specified registry value on 64 bit systems." name="SetRegistryValue64" continueOnFail="false">

                   <Parameter xsi:type="StringParameter" name="RegistryPath" value="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\ConsentPromptBehaviorAdmin" />

                   <Parameter xsi:type="StringParameter" name="Value" value="0" />

                   <Parameter xsi:type="EnumParameter" name="DataType" value="Integer" />

                 </Statement>

                 <Statement description="Write the selected directory, subdirectories and files to the machine at the path specified." name="WriteDirectory" continueOnFail="false">

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

                   <Parameter xsi:type="StringParameter" name="SourceDirectory" value="VSASharedFiles\ccleaner64\" />

                   <Parameter xsi:type="StringParameter" name="Param3" value="" />

                 </Statement>

                 <Statement description="Execute the specified file - full path to file required." name="ExecuteFile" continueOnFail="false">

                   <Parameter xsi:type="StringParameter" name="Path" value="#vAgentConfiguration.AgentTempDir#\ccleaner\ccleaner64.exe" />

                   <Parameter xsi:type="StringParameter" name="Arguments" value="/AUTO" />

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

                   <Parameter xsi:type="BooleanParameter" name="WaitComplete" value="True" />

                 </Statement>

                 <If description="">

                   <Condition name="CheckVariable">

                     <Parameter xsi:type="StringParameter" name="VariableName" value="#UACValue#" />

                     <Parameter xsi:type="EnumParameter" name="Condition" value="Exists" />

                     <Parameter xsi:type="StringParameter" name="Value" value="" />

                   </Condition>

                   <Then>

                     <Statement description="Set the specified registry value on 64 bit systems." name="SetRegistryValue64" continueOnFail="false">

                       <Parameter xsi:type="StringParameter" name="RegistryPath" value="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\ConsentPromptBehaviorAdmin" />

                       <Parameter xsi:type="StringParameter" name="Value" value="#UACValue#" />

                       <Parameter xsi:type="EnumParameter" name="DataType" value="Integer" />

                     </Statement>

                   </Then>

                 </If>

                 <Statement description="Write an Entry into the Procedure Log" name="WriteScriptLogEntry" continueOnFail="false">

                   <Parameter xsi:type="StringParameter" name="Comment" value="ccleaner completed" />

                 </Statement>

               </Else>

             </If>

           </Then>

           <Else>

             <Statement description="Write an Entry into the Procedure Log" name="WriteScriptLogEntry" continueOnFail="false">

               <Parameter xsi:type="StringParameter" name="Comment" value="ccleaner failed: user not logged in" />

             </Statement>

           </Else>

         </If>

       </Body>

     </Procedure>

    </ScriptExport>

  • Thank you!

    Works like a charm. I'll use that instead.