Monday, August 2, 2021

How to launch a bat file in hidden mode using vbscript

 I have bat file to launch vlc player.


Just a simple one 😊



"C:\Program Files\VideoLAN\VLC\vlc.exe"

When I launch it by double cliking it.
A command prompt window also launched as below.
 

So below vbscript will launch the cmd/bat file in hidden mode.

strPath = Wscript.ScriptFullName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPath)
strFolder = objFSO.GetParentFolderName(objFile)

'MsgBox(strFolder)

Set WshShell = CreateObject("WScript.Shell") 
WshShell.Run chr(34) & strFolder & "\a.bat" & Chr(34), 0
Set WshShell = Nothing

Now, only vlc window will be visible, not the cmd.exe window

No comments:

Post a Comment