I am trying to shutdown Windows at specific time every day.
I am using task scheduler to shutdown Windows at a specific time. I am using a batch a file for this which is working.
set /p a="Are you turn off computer (y/n)"
if %a%==y (shutdown.exe /s /t 00) else (echo "")
I want to add some other functions in that. I already added user input and if else statement which ask from user to shutdown Windows or not.
Now I want to add a command which checks and executes shutdown command if user does not give any input within a certain time, but I don't know how to do this.
use the choice command:
choice /t 10 /d y /m "Shutdown"
if errorlevel 2 (echo that's a no & goto :eof)
shutdown /s /t 0
/t 10
gives a timeout of 10 seconds.
/d y
is the default (what's chosen after the timeout)
/m "Shutdown
is the prompt string.