Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 948
kno010 Avatar asked Aug 07 '17 14:08

kno010


2 Answers

If you're still looking for an answer to this, I found something recently that none of these threads seem to mention. I don't have any reputation so can't add it to the other threads so I'm putting it here.

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.

like image 171
Stego27 Avatar answered Oct 21 '22 07:10

Stego27


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 : https://www.winhelponline.com/blog/run-bat-files-invisibly-without-displaying-command-prompt/

Source MSDN : https://msdn.microsoft.com/en-us/library/d5fk67ky(VS.85).aspx

like image 26
Shim-Sao Avatar answered Oct 21 '22 06:10

Shim-Sao