Package - minimize window when running loop command (do not start minimizing)
I am wondering if there is a way to minimize the batch window after running a specific command. I already know start / min and tricks to get START to minimize the window, but what about it doing a loop or timeout?
Let's say:
echo Hello!
timeout /t 100
:COMMAND TO MINIMIZE WINDOW WHILE TIMEOUT IS RUNNING
Right now I am calling autoit script on the bat file to hide the window while the command is running:
WinSetState($application_name, "", @SW_HIDE)
but I'm looking for a clean batch / powershell / vbs solution that can be coded directly into the .bat file.
Thank you for your time!
source to share
This will be done. However, you need to do the minification before the timeout, as you did in the batch. The timeout will now run after minimizing the window. This example will save the window during ping so you can minimize it.
echo Hello!
ping 127.0.0.1
if not DEFINED IS_MINIMIZED set IS_MINIMIZED=1 && start "" /min "%~dpnx0" %* && exit
timeout /t 100
exit
source to share
You can minify the command line during run, but you need two additional scripts: windowMode and getCmdPid.bat :
@echo off
echo Hello!
call getCmdPid >nul
call windowMode -pid %errorlevel% -mode minimized
timeout /t 100
call getCmdPid >nul
call windowMode -pid %errorlevel% -mode normal
source to share