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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vb to silently call batch is not working

Status
Not open for further replies.

Briandr

MIS
Jul 11, 2003
177
US
Hi,

This one line vbscript calls a batch file to run silently. The batch file is opening a window. Can someone help.

vbcommand:

CreateObject("Wscript.Shell").Run "%TEMP%\AltirisCleanup\AAInstall.bat",0,True

batch:

If [%ERRORLEVEL%] == [0] (
echo X86
cd %systemroot%\system32
If exist "CleanupCompleted.txt" exit
call :CLEANUP
call :FILEMOVE1
) ELSE (
echo AMD64
cd %systemroot%\sysnative
If exist "CleanupCompleted.txt" exit
call :CLEANUP
call :FILEMOVE2
)

:CLEANUP
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
echo rmdir "%AgentDir%\TaskManagement\cache" /s /q
echo rmdir "%AgentDir%\TaskManagement\status" /s /q
echo rmdir "%AgentDir%\TaskManagement\statusXml" /s /q
REM echo rmdir "%AgentDir%\TaskManagement\lti" /s /q
echo ping localhost -n 30
echo "%AgentDir%\aexagentutil" /start
echo exit /b
) > %tempbat%

REM Executes temporary batch file
start "" /MIN %tempbat%

Set RegVar=HKLM\Hardware\Description\System\CentralProcessor\0

REG.exe Query %RegVar% 2>NUL | find /I /N "x86">NUL

exit /b

:FILEMOVE1
COPY /Y "%~dp0\CleanupCompleted.txt" "%systemroot%\system32\CleanupCompleted.txt"
exit /b

:FILEMOVE2
%systemroot%\sysnative\cmd.exe /c copy /y "%~dp0\CleanupCompleted.txt" "%systemroot%\system32\CleanupCompleted.txt"
exit /b

I got the batch from a Symasntec website so not quite sure what could be wrong. In case your wondering how the text file gets copied out, I have the vb and batch in a WinRAR self extracting EXE. So the text file is extracted from there.

Thanks.
 
Your vbscript one-liner is correct, it's something inside the batch causing the window. I think it's the "start" command executing a batch within the batch. Try replacing this line:
start "" /MIN %tempbat%

With this:
Call %tempbat%
 
Granted you can invoke a batch program from a VBScript but why? Seems to me that you would be better off to re-write the batch program in VBScript and that way the batch program will not open a window.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top