How to make a batch file minimize itself
This means that the window will remain on screen after the command has finished. You can alter that behavior by explicitly running cmd. Alternatively, you can create a shortcut to the batch file are PIF files still around , and then alter its properties so that it starts minimized. The only way I know is by creating a Windows shortcut to the batch file and then changing its properties to run minimized by default. Also -window hidden and -window normal is available to hide completely or restore.
One way to 'minimise' the cmd window is to reduce the size of the console using something like The advantage is that it works under WinPE, bit or bit, and does not require any 3rd party utility. It will immediately minimize as soon as it opens the program. You will only see a brief flash of it and it will disappear. Yet another free 3rd party tool that is capable of minimizing the console window at any time not only when starting the script is Tcl with the TWAPI extension:.
I prefer it to the much lighter min. You can minimize the command prompt on during the run but you'll need two additional scripts: windowMode and getCmdPid. One option is to find one of the various utilities that can change the window state of the currently running console window and make a call to it from within the batch script.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How do I minimize the command prompt from my bat file Ask Question. Asked 9 years, 11 months ago. Active 6 months ago. Viewed k times. Any ideas on how to do this? Improve this question. Etheryte Matt Elhotiby Matt Elhotiby Add a comment.
Active Oldest Votes. Remarks You have to reserve some variable name to use it as a flag. The script should be ended with exit , otherwise the cmd window wouldn't be closed after the script execution. This means that the window will remain on screen after the command has finished. You can alter that behavior by explicitly running cmd. Alternatively, you can create a shortcut to the batch file are PIF files still around , and then alter its properties so that it starts minimized. The only way I know is by creating a Windows shortcut to the batch file and then changing its properties to run minimized by default.
It will immediately minimize as soon as it opens the program. You will only see a brief flash of it and it will disappear. One option is to find one of the various utilities that can change the window state of the currently running console window and make a call to it from within the batch script.
You can run it as the first thing in your batch script. Therefore, the "cloaking" of the console has to be started before starting the batch file, which means using an alternative scripting language to start the command interpreter hidden.
If a console window is visible already, but you want to start another batch file minimized, use one of the following commands:. If a console window is visible already, but you want to start another batch file hidden, use one of the following commands:. EXE has to be used. Do not use the following commands in a batch file, as this batch file will run in a visible console window itself.
Make sure the batch file closes its own window in all circumstances , because you won't be able to see whether it does close or keep running "forever".
0コメント