Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: How do I Un-minimize the prompt after an user minimized it?  (Read 3722 times)

0 Members and 1 Guest are viewing this topic.

AlexRoda

    Topic Starter


    Newbie

    • Experience: Familiar
    • OS: Windows 10
    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 not

    Salmon Trout

    • Guest
    Re: How do I Un-minimize the prompt after an user minimized it?
    « Reply #1 on: July 11, 2019, 10:29:20 AM »
    You 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"
    « Last Edit: July 11, 2019, 11:20:19 AM by Salmon Trout »

    Salmon Trout

    • Guest
    Re: How do I Un-minimize the prompt after an user minimized it?
    « Reply #2 on: July 11, 2019, 11:19:13 AM »
    Of course you don't have to write second.bat every time.

    Salmon Trout

    • Guest
    Re: How do I Un-minimize the prompt after an user minimized it?
    « Reply #3 on: July 11, 2019, 01:47:25 PM »
    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


    AlexRoda

      Topic Starter


      Newbie

      • Experience: Familiar
      • OS: Windows 10
      Re: How do I Un-minimize the prompt after an user minimized it?
      « Reply #4 on: July 12, 2019, 06:13:51 AM »
      Thank you very much Salmon Trout!
      It was exactly what I needed!