Batch File Variable Help

E-machines / T3120
February 6, 2009 at 15:00:01
Specs: Windows XP Pro SP2, AMD Semptron - 1.5gb RAM
I'm making a batch file in which a variable is stored and then a
number is subtracted from it. Lets say I made a variable called
MyVar and then if someone goes to a certain section, then a
number is subtracted from it.

@echo off
set MyVar=70
echo Hello! Please select an option...
echo 1 - Go!
echo 2 - Exit
set input=
set /p input=Selection:
if %input%==1 goto go
if %input%==2 goto exit

*** Subtracting Code Here ***
echo 60 has been subtracted from MyVar
echo The Variable is now: %MyVar%
ping localhost -n 4 >nul


So how would I go about doing that?

If you give up, might as well give up everything in life.

See More: Batch File Variable Help

Report •

February 6, 2009 at 16:49:51
set /a myvar-=<number>

Just be aware that set /a has large number limitations, for 32 bit windows anything outside of -2147483648 to 2147483647 may cause problems.

Report •
Related Solutions

Ask Question