|Hello, I'm really new to Batch scripting, I've been creating a batch script that turns the user DEP ON or OFF.|
My problem right now is that my if statement is not working the way I wish it would.
Anyways what it does/doesn't is simple:
1 - Ask the users if they wish to turn the DEP ON or OFF.
2- Ask the users if they wish to restart the computer so the changes can be applied.
3- if They say Y to restart it will restart their pc in 30 seconds.
4- If answering Y to the restart question, it ask if they wish to abort the shutdown -r command.
5- If answering N cls the window and tell them that they still need to restart for the changes to apply.
My problem right now is that number 5 when I answer No for if I would like to restart the computer now the second message that asks the user if they wish to abort the reboot of their computer still show up.
Not sure why.
Here is my code:
echo ***** YOU NEED TO RESTART YOUR COMPUTER SO THE CHANGES CAN BE APPLIED! *****
echo ***MAKE SURE TO SAVE ALL YOUR DOCUMENTS BEFORE RESTARTING YOUR COMPUTER OR YOU WILL LOOSE EVERYTHING!!***
set /p RESTART= WOULD YOU LIKE TO RESTART YOUR COMPUTER NOW?(Y/N):
if /I %RESTART%==Y (
echo YOUR COMPUTER WILL BE REBOOTED IN 30 SECONDS!!!
shutdown -r -f -t 30
set /p ABORT= WOULD YOU LIKE TO ABORT THE REBOOT?(Y):
if /I %ABORT%==Y (
echo YOU ABORTED THE REBOOT OF YOUR COMPUTER.
) else (
echo YOUR COMPUTER WILL REBOOT SOON!
I would appreciate any help and suggestions to change my code for better. Like I stated above I'm really new to batch scripting.
Well thank you for your help and time, have a nice one!