I have this code:
@echo off
if not exist vars.bat (
type nul>vars.bat
)
:menu
cls
echo 1) Make new variable
echo 2) View a variable
echo.
set /p cin=Select option:
if %cin%==1 goto mkvar
if %cin%==2 goto getvar
goto menu
:mkvar
cls
set /p var=Enter variable name:
set /p val=Enter value:
echo set %var%=%val%>>vars.bat
goto menu
:getvar
cls
if exist vars.bat call vars.bat
cls
set /p var=Enter a variable:
setlocal enabledelayedexpansion
echo Value of %var% is !%var%!
endlocal
pause
goto menu
And I want it to act as a login code that you can select NEW ACCOUNT or LOGIN and then it does that. Any help please?
save login
Moderator: DosItHelp
Re: save login
Here is your Code
I had to change
so it can get the value assigned to the name
Code: Select all
@echo off
cls
Title Menu
mode 73,25
::===============================
SETLOCAL EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
set "DEL=%%a"
)
::===============================
color 0f
if not exist vars.bat (
type nul>vars.bat
)
:Main
echo:&echo:&echo:&echo:&echo:
call :color 07 " =========================" &echo:
call :color 07 " =" & call :color 0e " This is Test Menu" & call :color 07 " =" & echo:
call :color 07 " =========================" &echo:&echo:
call :color 0a " (1) Log-In" &echo:&echo:
call :color 0b " (2) New Account" &echo:&echo:
call :color 07 " (3) Exit" &echo:&echo:
echo:&echo:&echo:
set /p "cin=Select option:"
if %errorlevel%==1 cls & goto Main
if %cin%==1 goto login
if %cin%==2 goto newaccount
if %cho1%==3 goto EOF
echo Invalid choice.
goto Main
:login
set /p var=Enter Account Name:
For /f "tokens=2 delims==" %%a in ('find /i "%var%=" "vars.bat"') DO echo Value of %var% is %%a
pause
cls
goto Main
:newaccount
set /p var=Enter Account Name:
set /p val=Enter Password:
echo %var%=%val%>>vars.bat
cls
goto Main
::===============================
:color
echo off
<nul set /p ".="%DEL% " " >> "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1
goto :eof
::===============================
I had to change
Code: Select all
cls
if exist vars.bat call vars.bat
cls
set /p var=Enter a variable:
setlocal enabledelayedexpansion
echo Value of %var% is !%var%!
endlocal
pause
so it can get the value assigned to the name