Hiding CMD when running a batch file

Can I hide the command line when running a batch file?

+4
source share
2 answers

This method works for me, however I also found this and this and this , etc. etc. .

+3
source

I am sure I like this method best. Copy and paste the code below into the .vbs file. From there you will invoke the batch file ... so make sure you edit the last line to indicate the path and name of the batch file:

Const HIDDEN_WINDOW = 12 strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set objStartup = objWMIService.Get("Win32_ProcessStartup") Set objConfig = objStartup.SpawnInstance_ objConfig.ShowWindow = HIDDEN_WINDOW Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process") errReturn = objProcess.Create("C:\PathOfFile\name.bat", null, objConfig, intProcessID) 

It definitely worked for me. Comments are welcome :)

0
source

All Articles