mercredi 1 août 2018

need help troubleshoooting windows choice loop

setlocal EnableDelayedExpansion
:adapterloopstart
echo.
echo please enter the type of adapter you would like to create
echo 1. Host-Only
echo 2. Internal
echo.

set ADAPTYPE=
choice /C:12
if ERRORLEVEL 2 set ADAPTYPE=intnet
goto adapterconfirm
if ERRORLEVEL 1 set ADAPTYPE=hostonly
goto adapterconfirm
REM If you got here, it wasn't 1, 2
goto adapterloopstart
echo %ADAPTYPE%

:adapterconfirm
echo %ADAPTYPE%
set confirmadapter=
set /p confirmadapter=Do you wish to create a "%ADAPTYPE%" network (y,n):
if not '%confirmadapter%'=='' set confirmadapter=%confirmadapter:~0,1%
if '%confirmadapter%'=='y' goto adapterend
if '%confirmadapter%'=='n' goto adapterloopstart
ECHO "%choice%" is not valid, try again
:adapterend

the above code gives the following string: Do you wish to create a "" network (y,n):

it does not display the variable

how can i fix this so i know it saved the variable with correct choice for when i wish to re-run this code later so i can get feedback of whats going on?

Aucun commentaire:

Enregistrer un commentaire