Any idea how to achieve this ?
Code: Select all
@echo off
setlocal EnableDelayedExpansion
set /a UserProfileNo=0
FOR /F "delims=" %%I IN ('dir /a:d /b "%SystemDrive%\Users\"') do (
set "UserProfileName=%%~I"
set /a UserProfileNo+=1
set "UserProfileName[!UserProfileNo!]=!UserProfileName!"
)
FOR /L %%k IN (1, 1, %UserProfileNo%) DO echo %%~k !UserProfileName[%%~k]!
set /p choice=Enter a Profile Number:
FOR %%f IN (%choice%) DO if "!UserProfileName[%%~f]!" == "" (
echo Error in the input
goto end
)
echo NO Error in the input
:end
pause
exit
Thank you