Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
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.
E.X:@echo off
set MyVar=70
echo Hello! Please select an option...
echo.
echo 1 - Go!
echo 2 - Exit
set input=
set /p input=Selection:
if %input%==1 goto go
if %input%==2 goto exit:go
*** Subtracting Code Here ***
cls
echo 60 has been subtracted from MyVar
echo The Variable is now: %MyVar%
ping localhost -n 4 >nul:exit
cls
exitSo how would I go about doing that?
If you give up, might as well give up everything in life.

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.

![]() |
Help with batch script
|
batch autorun and autopla...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |