I was looking for a simple way to catch user input after Crtl+C is pressed and Terminate batch job (Y/N)? prompt is shown in a Win 10 Cmd window, but amazingly can't find any on the web. For example, depending on user input:
Code: Select all
if "y" command1 else if "n" command2
What variable Cmd sets for user input in this case? Any suggestions how to catch?
Related, I found a suggestion how to ignore Ctrl+C altogether here, but could you explain what variable %~1 means in this code, and what the code does:
Code: Select all
@ECHO OFF
IF "%~1"=="–FIX_CTRL_C" (
SHIFT
) ELSE (
CALL <NUL %0 –FIX_CTRL_C %*
GOTO :EOF
)
Another question... When
Code: Select all
shutdown /l /f