According to my comment, you are closing the opened If
parenthesis with the closing /N)
parenthesss prematurely.
You could therefore just escape that parenthesis with a caret, ^)
:
:paswretry
Set /P "pasw=Wachtwoord: "
Set /P "paswconfirm=Type het wachtwoord overnieuw: "
If "%pasw%"=="%paswconfirm%" (
Echo Weet je het zeker? Het wachtwoord word: %pasw%
Choice /C YN /N /M (Y/N^)
If "%ErrorLevel%"=="1" (
Echo 1
) Else (
Echo 2
)
)
Or you could doublequote the message text as shown in the examples within the usage information, (output when entering Choice /?
at the Command Prompt):
:paswretry
Set /P "pasw=Wachtwoord: "
Set /P "paswconfirm=Type het wachtwoord overnieuw: "
If "%pasw%"=="%paswconfirm%" (
Echo Weet je het zeker? Het wachtwoord word: %pasw%
Choice /C YN /N /M "(Y/N)"
If "%ErrorLevel%"=="1" (
Echo 1
) Else (
Echo 2
)
)
However the Choice
command works automatically using [Y,N]?
, and will therefore need no additional options.
You should use either this:
:paswretry
Set /P "pasw=Wachtwoord: "
Set /P "paswconfirm=Type het wachtwoord overnieuw: "
If "%pasw%"=="%paswconfirm%" (
Echo Weet je het zeker? Het wachtwoord word: %pasw%
Choice
If ErrorLevel 2 (
Echo 2
) Else (
Echo 1
)
)
this, (better):
:paswretry
Set /P "pasw=Wachtwoord: "
Set /P "paswconfirm=Type het wachtwoord overnieuw: "
If Not "%pasw%"=="%paswconfirm%" GoTo paswretry
Echo Weet je het zeker? Het wachtwoord word: %pasw%
Choice
If ErrorLevel 2 (
Echo 2
) Else (
Echo 1
)
or this, (even better):
:paswretry
Set /P "pasw=Wachtwoord: "
Set /P "paswconfirm=Type het wachtwoord overnieuw: "
If Not "%pasw%"=="%paswconfirm%" GoTo paswretry
Echo Weet je het zeker? Het wachtwoord word: %pasw%
Choice
Echo %ErrorLevel%
In the latter two examples I've used GoTo paswretry
on line 4
; that of course can be changed to GoTo SomethingElse
, (even :EOF
to exit the script block), as required