So I want to code an optional, where the user can input y or n, shut down. And this is what I have been trying:
@echo off
echo ---WARNING---
echo.
echo DO YOU WANT YOUR COMPUTER TO SHUTDOWN? (y/n)
If /I "%Input%"=="y" goto yes
If /I "%Input%"=="n" goto no
:yes
shutdown /s
:no
pause
Am I along the right track even?
Try adding this.
set /p Input=Enter Yes or No:
I have also added a goto
because if you typed something that isn't a yes or a no then it would have automatically gone to yes. Failing the below code you could add this but the code at the bottom should work.
set /P INPUT=Type input: %=%
If %INPUT%=="y" goto yes
If %INPUT%=="n" goto no
Your code should be like this:
@echo off
echo ---WARNING---
echo.
echo DO YOU WANT YOUR COMPUTER TO SHUTDOWN? (y/n)
set /p Input=Enter Yes or No:
If /I "%Input%"=="y" goto yes
goto no
:yes
shutdown /s
:no
pause
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With