Since this batch behaves in ways I am not expecting (came from Symantec) I have begun to try and rewrite with the help of a colleague to vbscript. Can you help with the missing pieces?
Batch
REM Get the Altiris Agent install path
FOR /F "tokens=2*" %%A IN ('REG.EXE QUERY "HKLM\Software\Altiris\Altiris Agent" /V "installdir"') DO SET AgentDir=%%B set tempbat=%temp%\AgentClean.bat"
REM Create temporary batch file to execute while the agent restarts echo "%AgentDir%\aexagentutil" /stop > %tempbat% echo rmdir "%AgentDir%\TaskManagement\cache" /s /q >> %tempbat% echo rmdir "%AgentDir%\TaskManagement\status" /s /q >> %tempbat% echo rmdir "%AgentDir%\TaskManagement\statusXml" /s /q >> %tempbat%
REM echo rmdir "%AgentDir%\TaskManagement\lti" /s /q >> %tempbat% -- remove away the REM, from this line only if you are running on 7.1 and above
echo ping localhost -n 30 >> %tempbat%
echo "%AgentDir%\aexagentutil" /start >> %tempbat% echo exit >> %tempbat% REM Executes temporary batch file start "" /MIN %tempbat%
VB
ON ERROR RESUME NEXT
DIM SRCPath, WshShell, fso
DIM CLEANUPCOMPLETED = FALSE
Set fso = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
SRCPath = WshShell.RegRead("HKLM\Software\Altiris\Altiris Agent\installdir")
Return = WshShell.Run(CHR(34) & SRCPath & "\AeXAgentUtil.exe" & CHR(34) & " /stop", 0 , TRUE)
fso.DeleteFolder(SRCPath & "\TaskManagement\cache")
fso.DeleteFolder(SRCPath & "\TaskManagement\status")
fso.DeleteFolder(SRCPath & "\TaskManagement\status")
fso.DeleteFolder(SRCPath & "\TaskManagement\statusXml")
fso.DeleteFolder(SRCPath & "\TaskManagement\lti")
WScript.Sleep 5000
Return = WshShell.Run(CHR(34) & SRCPath & "\AeXAgentUtil.exe" & CHR(34) & " /start", 0 , TRUE)
'*****************************************************
Public SUB filechk()
CLEANUPCOMPLETED = FALSE
If fso.FileExists("C:\windows\system32\cleanupcompleted.txt") Then CLEANUPCOMPLETED = TRUE : Exit SUB
END SUB
Any and all help graciously appreciated.