Use "Cmd /C" but Hide the Console Window

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?

2

7 Answers

Use the command start with switch /min to start cmd in minimized window:

start /min cmd /c "full path to my batch file"
3
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.

0

I found this solution :

Create a launch.vbs file and add

Set WshShell = CreateObject("WScript.Shell") 
WshShell.Run chr(34) & "C:\Batch Files\syncfiles.bat" & Chr(34), 0
Set WshShell = Nothing

Replace "C:\Batch Files\syncfiles.bat" by your absolute or relative path file name.

Source :

Source MSDN : (VS.85).aspx

Right-click on the shortcut icon and choose "Properties."

On the "Shortcut" tab, choose the "Run" type you desire from the dropdown menu.

The START command has a /B switch to start without creating a window. Use START /? to read all about it.

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.

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"

Create a VBScript file as a shell to start it.

' Launcher.vbs
If WScript.Arguments.Count = 0 Then
  WScript.Quit 1
End If

Dim WSH
Set WSH = CreateObject("WScript.Shell")
WSH.Run "cmd /c " & WScript.Arguments(0), 0, False

You may want to embed this as a Here Document in your batch file. See heredoc for Windows batch?

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest