CMD

Run batch file minimized

Run batch file minimized

If you are running scheduled Windows batch files, then sometimes it could be more convenient to run batch file minimized.

Run batch file minimized from Windows Task Scheduler

Here is a simple example of how to schedule batch files in Windows Task Scheduler. But if you want to run it minimized, then you have to make adjustments in the Actions tab.

Action: Start a program

Program/script: cmd

Add arguments (optional):

 /c start /min "My title" C:\Aplikacijas\NameOfMyFile.bat ^& exit

“^& exit” at the end is necessary to close the CMD window after the batch file is executed.

Run batch file minimized from Windows Task Scheduler

Minimize batch file from another batch file

start /min  "My title" C:\Aplikacijas\NameOfMyFile.bat

exit

Exit at the end is used to close the current CMD window. Use it only if necessary.
The title is optional. You can also run it like this

start /min  "" C:\Aplikacijas\NameOfMyFile.bat

If you want to just run batch file and keep doing other things, it is the same as above.

Batch file minimized from itself

If you want to minimize the cmd window after running it, I recommend this post from StackOverflow. Here is an example with a batch file that contains a line with R script execution.

if not DEFINED IS_MINIMIZED set IS_MINIMIZED=1 && start "BO darbi" /min "%~f0" %* && exit

"C:\Program Files\R\R-3.4.3\bin\x64\Rscript.exe" "C:\MyFolder\MyRscrip.R"

exit

Other CMD related posts

If you want to found out more cool stuff about Windows CMD, take a look at other Datacornering posts about this topic.




0 comments on “Run batch file minimized

Leave a Reply

Your email address will not be published. Required fields are marked *