lundi 4 février 2019

"If" Statment closes script randomly [Batch]

The if statement just closes the batch file.

I have already tried using [] instead of "" in the if statement. I have tried this code it windows 8.1, server 2016, and Windows 10.

set Operating=
:: What operating system
set /P choice=Windows Server[Y/N]?
echo %choice%
if /I [%choice%]==[Y] (
    set Operating=Server2016
) else(
    set /P choice=Windows 10[Y/N]?
    if /I "%choice%" EQU "Y"(
        set Operating=Windows10
    ) else (
        set Operating=Windows81
    )
)
echo You are using %Operating%

I expect a user to answer the qusitons with Y/N and than output there option at the end. But, all it dose is close.

Aucun commentaire:

Enregistrer un commentaire