I Made A Batch File That Will Tell Me If I Aborted A Shutdown Successfully Or Not. If There Was No Shutdown In Progress, It Would Tell Me "No Shutdown Was Initiated". My Code Is all working except i was wondering if there is a way to take out the bit of code that will come up if there is no shutdown initiated in the first place
@echo off
Title Abort
Shutdown -a
if Not Errorlevel 1 (
goto Good
) Else (
goto Bad
)
:Good
Echo Success!
Pause>Nul
Exit
:Bad
Echo No Shutdown Was initiated.
Pause>Nul
Exit
}
This Would Show If I Ran The Code With No Shutdown Initiated And What I Don't Want. https://i.sstatic.net/n5F2C.png (Link To My Pic)
Its Not a MAJOR Problem, But It Would Be Helpful. Thanks, Jake
just suppress the errormessage:
shutdown -a 2>nul
by the way: you could shorten your code dramatically:
@echo off
Title Abort
Shutdown -a 2>nul && echo Shutdown aborted || echo No Shutdown Was initiated.
Pause>Nul
Exit
&&
works as "If previous command was successful then"
||
works as "if previous command failed then"