Reputation: 675
I could not find a good answer for my problem. Perhaps someone has already the answer and would be very kind to share it. I am running a batch file and, at a certain time, I would like to minimize the batch window. Some codes later, maximize or return it to the actual size.
@echo off
mode con cols=100 lines=100
echo My batch is NOT minimized. This message is from a normal window!
start "window_will_be_minimized" k:\Folder20\MiniMaxi.exe
start /wait "" cmd /c c:\Folder00\Drawing.exe
Drawing.exe is now running.
REM --- At this point my batch window is minimized and the MiniMaxi.exe is closed
REM --- until the Drawing.exe is closed.
Drawing.exe is now closed.
REM --- Immediatelly my batch window must return to its previous size.
Therefore, the MiniMaxi.exe will be launched and then closed
start "window_will_be_MAXImized" k:\Folder20\MiniMaxi.exe
echo Again, this message is from a normal window
pause > nul
exit /b
Thank you in advance
Upvotes: 1
Views: 3382
Reputation: 128
I cannot do what you ask however, as mentioned you can spawn batch files in a minimised, maximised or default state. The following will create a new batch xmise.bat
start it minimised & exit. The new batch xmise.bat
will start Drawing.exe, wait, launch the original batch (custom sized window) & exit. Then the original batch will delete the created batch xmise.bat
.
You could write the
somes codes later / hidden "cleanup" functonalities
to xmise.bat
@echo off
mode con cols=100 lines=100
if "%var%"=="" echo My batch is NOT minimized. This message is from a normal window!
if "%var%"=="created" echo Again, this message is from a normal window
pause>nul
if "%var%"=="created" del xmise.bat&cls&goto :end
set var=created
echo start /wait "" "Drawing.exe">xmise.bat
echo start "" cmd /c "%~n0.bat">>xmise.bat
echo exit>>xmise.bat
start /min xmise.bat
:end
exit
Drawing.exe is now running.
REM --- At this point the xmise.bat window is minimized and the original.bat (%~n0.bat) exits
REM --- until the Drawing.exe is closed.
Drawing.exe is now closed.
REM --- Immediatelly my batch window must return to its previous size.
REM --- the original.bat will be relaunched custom size, xmise.bat exits, & then is deleted.
Upvotes: 0
Reputation: 1470
Bad news: batch files cannot control whether their own window is min or max; this must be done when calling a batch file, at which time you can tell it to run /min, /max, or neither/default. The new batch will not be aware of this setting. As EitanT mentioned, it will have to be managed by an application. Only when starting a new batch can you control if that one will be min, max, or normal.
For timing, the only control you have is either pause (as you did in your script), or some method of delaying the continuation of the script by doing something like this delay of about 10 seconds:
ping -n 10 localhost >nul
Upvotes: 1