Use "cmd /c" but hide the console window

Viewed 49944

I have a shortcut running this command when clicked: cmd /c "full path to my batch file". When I use it, it does what it is supposed to do, but in the process the ugly console window pops up. Is there any way to make this command start a hidden or at least minimized window?

7 Answers
powershell "start <path of batch file> -Args \"<batch file args>\" -WindowStyle Hidden"

This can be placed in a separate batch file which, when called, will terminate immediately while your batch file executes in the background.

From ' Args ' to ' \" ' can be excluded if your batch file has no arguments.

' -v runAs' can be added before the end quote to run your batch file as an administrator.

This will create a separate process (without a window), and not block parent window so it can continue your main work:

start /b cmd /c "full path to my batch file"

Use AutoHotKey file. Download and install AutoHotKey first.

suppose you have an 1.bat

you'll create a C:\2.ahk, whose content is

Run C:\1.bat,,Hide
return

and you'll create a 3.lnk, and right click it, click property, then set the Target to

"C:\Program Files\AutoHotkey\AutoHotkey.exe" C:\2.ahk

Then you'll get what you want.

This way, you can attach the 3.lnk to your taskbar or start menu, and also change its icon.

The start method can only be used in a bat, which can't be added to taskbar or changed icon.

Related