Subscribe to Windows IT Pro
April 11, 2005 12:00 AM

JSI Tip 9242. How can I hide a batch window?

Windows IT Pro
InstantDoc ID #83406
Rating: (10)


Using only built-in tools, I have scripted HideBatch.bat to run a batch script hidden.

The syntax for using HideBatch.bat is:

HideBatch BatchFile [Param1 Param2 ... ParamN]

Where:

BatchFile is the path to the batch file and ParamX are optional parameters.

HideBatch.bat contains:

@echo off
if {%1}=={} @echo Syntax: HideBatch BatchFile [Param1 Param2 ... ParamN]&goto :EOF
setlocal
set VBS="%TEMP%\HideBatch.vbs"
if exist %VBS% goto Runit
@echo dim obj, obj1, obj2, objArgument>%VBS%
@echo Set WshShell = WScript.CreateObject("WScript.Shell")>>%VBS%
@echo Set objArgument = Wscript.Arguments>>%VBS%
@echo obj1=objArgument(0)>>%VBS%
@echo obj2=Replace(obj1, "```", """")>>%VBS%
@echo obj = WshShell.Run(obj2, 0)>>%VBS%
@echo set WshShell = Nothing>>%VBS%
:Runit
set param=%*
set param="%param:"=```%"
cscript //nologo %VBS% %param%
endlocal



Related Content:

ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.