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.

- system temp
- user temp
- browser cache
- error reports
- start-run history

Works for currently logged-in user only. Will fail if user not logged in.

Bypasses UAC prompt in Vista/7/2008 OS's.

Safe for servers and workstations.
">
<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>
<Condition name="Windows 32 or 64 Bit Check">
<Parameter xsi:type="EnumParameter" name="Condition" value="NotExists" />
<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 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 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" />
<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="" />
<Parameter xsi:type="StringParameter" name="Value" value="#UACValue#" />
</Then>
</If>
<Statement description="Write an Entry into the Procedure Log" name="WriteScriptLogEntry" continueOnFail="false">
<Parameter xsi:type="StringParameter" name="Comment" value="ccleaner completed" />
<Else>
<Statement description="Set the specified registry value on 64 bit systems." name="SetRegistryValue64" continueOnFail="false">
<Parameter xsi:type="StringParameter" name="SourceDirectory" value="VSASharedFiles\ccleaner64\" />
<Parameter xsi:type="StringParameter" name="Path" value="#vAgentConfiguration.AgentTempDir#\ccleaner\ccleaner64.exe" />
</Else>
<Parameter xsi:type="StringParameter" name="Comment" value="ccleaner failed: user not logged in" />
</Body>
</Procedure>
</ScriptExport>
Thank you!
Works like a charm. I'll use that instead.