|
Answer» My problem is quite simple And I imagine it has a really easy way to fix it But no matter how much I searched for it I can't find it How do I Un-minimize the PROMPT after an user minimized it?
I'm making a simple timer routine timeout for an hour choice If the user don't input anything it sends the computer to hibernation The problem I'm facing is Since it is a program that should stay running on the background until the timer is over its usually minimized I just need a way to Un-minimize it when the timer runs out so that the user can decide if it wants to continue or notYou can't get a batch to de-minimize ("restore") itself without using 3rd party utilities like cmdow.exe (for example).
cmdow http://www.commandline.co.uk/
However without any addons you can make one batch (minimized) execute another (not minimized) using the START command.
echo off
if exist second.bat DEL second.bat echo echo off >> second.bat echo title SECOND >> second.bat echo cls >> second.bat echo echo. >> second.bat echo echo ********************************** >> second.bat echo echo * YOU HAVE 30 SECONDS TO RESPOND * >> second.bat echo echo ********************************** >> second.bat echo echo. >> second.bat echo choice /T 30 /C yn /D y /M "Hibernate now Y/N? " >> second.bat echo if "%%errorlevel%%"=="2" exit >> second.bat
REM edit out the ECHO in capital letters REM when you are happy it works REM or insert your hibernate command instead echo ECHO shutdown /h /t 0 >> second.bat
REM delete these 2 lines when you have debugged REM and are happy echo PAUSE >> second.bat echo exit >> second.bat
title FIRST echo Please minimize me! set delay=60 REM or 3600 or whatever timeout %delay% start "" "second.bat"Of course you don't have to write second.bat every time. No need for a second file. Here's another method - the script is started with no command line parameter, then, after the timeout, the script starts itself again, not minimized this time, passing a parameter which makes it jump to a label where the choice, hibernate stuff happens.
echo off if "%1"=="2" goto second title FIRST echo Please minimize me! REM or 3600 or whatever set delay=60 timeout %delay% start "" "%~dpnx0" 2 exit
:second title SECOND echo ********************************** echo * YOU HAVE 30 SECONDS TO RESPOND * echo ********************************** echo. choice /T 30 /C yn /D y /M "Hibernate now Y/N? " if "%errorlevel%"=="2" exit
REM edit out the ECHO in capital letters REM when you are happy it works REM or insert your hibernate command here ECHO shutdown /h /t 0
REM delete these 2 lines when you have debugged REM and are happy pause exit Thank you very much Salmon Trout! It was exactly what I NEEDED!
|