DCUK6 Posted November 7, 2014 Posted November 7, 2014 (edited) Its Friday and i'm trying to create a script to shutdown the machines using the choice command to give a option to cancel. Heres what ive got @echo off choice /c:YN /n /m "This computer will shutdown in 2 minutes. Would you like to cancel this shutdown? Y to Cancel" /t:1 /d:N if errorlevel 2 (shutdown /s -t 0 -f) else echo. && echo Restart Canceled for 30 minutes. If I press Y then it cancels the shutdown. If I leave it to timeout it enters N but doesn't shutdown If I echo the errorlevel when N is pressed then 2 comes out. The cancel option works great but the shutdown option just repeats the script. Anyone able to help? Edited November 7, 2014 by DCUK6
cscc Posted November 12, 2014 Posted November 12, 2014 Something like this should work, if no input detected after 120 seconds it will shut down the PC. @echo off choice /C YN /D Y /T 120 /M "Shutdown [Y] Yes or [N] No?" IF errorlevel 2 goto shutdown_no IF errorlevel 1 goto shutdown_yes :shutdown_no exit :shutdown_yes shutdown /f /s /t 300 /c "Computer Shutting Down in 5 Minutes"
DCUK6 Posted November 12, 2014 Author Posted November 12, 2014 Thanks cscc, I've found the shutdown command in a bat file requires you to run as administrator. Just running the shutdown command doesn't however. Won't be able to use this. Trying to find a impero replacement. The power management is a bit broken for some reason as it tries to shut down computers not in the group.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now