Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

call batch silently from vbscript

Status
Not open for further replies.

Briandr

MIS
Jul 11, 2003
177
US
I am having a devil of a time getting this line to call my batch silently. Any ideas?

CreateObject("Wscript.Shell").Run chr(34) & "cmd.exe /c %TEMP%\AltirisCleanup\AACleanup.bat" & chr(34) & " /silent",0,true

 
Something like this maybe:
CreateObject("Wscript.Shell").Run("cmd.exe /c " & chr(34) & "%TEMP%\AltirisCleanup\AACleanup.bat" & chr(34) & " /silent"),0,true

 
Hi Geates,

It worked, but the batch file is still showing up in a command window. I think the issue might be is a batch file is being called from within a batch file. So while the VB command hides the first one, the second one is not being hidden. I think at least.
 
Posted at the same time... Same basic idea as Geates. Mine has parenthesis around the Run statement, which may not be necessary
 
Geates command skipped the "/silent" switch (which I recommend until you get it working anyway). Just add it back and it should work
 
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.


 
For starters, remove the "on error resume next" line, or you will never see run time errors, or be able to fix them
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top