2

I have a batch file that runs some commands and open some files in explorer. I want to happen these actions without opening any command prompt. Is it possible? If so, how?

I'm not using any other scripts like vbs. Thanks in advance.

RAVITEJA SATYAVADA
  • 2,503
  • 23
  • 56
  • 88

4 Answers4

9

Not exactly your answer as you probably don't wanna use VBS but yes, it'll make command prompt completely invisible.

  1. Save your code in a batch file lets say My.bat.

  2. Create a VBScript file lets say Master.vbs and call your My.bat file within it.

Lets assume your batch file is at C:\Test\My.bat then:

Master.vbs:

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

It'll run your batch file in invisible/hidden mode.

Sunny
  • 7,812
  • 10
  • 34
  • 48
  • I don't understand the OP's VBS aversion, **this** is definitely the best way of accomplishing the hiding goal. – Olek Wojnar Feb 13 '15 at 05:20
  • This should be the awarded answer, in my opinion. This is aces. – Jason P Sallinger Mar 16 '16 at 14:02
  • +1 Using double quotes in front of Start in a batch file such as in the answer below does NOT work on Windows 10/Office 2016 for me, but `Sunny's` answer does. http://stackoverflow.com/questions/14697739/how-to-automatically-close-cmd-window-after-batch-file-execution – Miqi180 Aug 14 '16 at 15:08
5

If at all possible, modify the batch file to run whatever program with the start command. By default, start returns immediately without waiting for the program to exit, so the batch file will continue to run and, presumably, exit immediately. Couple that with modifying your shortcut to run the batch file minimized, and you’ll only see the taskbar flash without even seeing a window onscreen.

nation best
  • 196
  • 8
  • Unfortunately, this doesn't work very well if you have a non-trivial batch file, especially if it needs to perform clean-up actions **after** the primary program exits. – Olek Wojnar Feb 13 '15 at 05:16
1

You can use Bat to exe file converter to convert the file to run in invisible mode as enunciated in this stackoverflow answer, image as follows

Community
  • 1
  • 1
Dev
  • 411
  • 3
  • 6
0

I found another, easier way: make a shortcut of the bat file, go to its properties and set execute to "minimize". This way the shortcut is your entry which instantly minimizes the created cmd and it wont even show in the taskbar. Works on Win11.