cmd - batch result me "echo off" instead the proper result -


i have little problem next code

@echo off title starting cls echo. echo checking running services... echo. timeout /t 2 /nobreak >nul tasklist /fi "imagename eq cmd.exe" /v | find /i /n "databaseserver" >nul if "%errorlevel%"=="1" ( cls echo. echo database not running, start! echo. start database.bat echo database running!  echo. timeout /t 4 /nobreak >nul ) tasklist /fi "imagename eq cmd.exe" /v | find /i /n "armaserver" >nul if "%errorlevel%"=="1" ( /f "tokens=1-4 delims=:.," %%a in ("%time%") (    set /a "ora=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100" ) echo %ora% pause cls echo. echo server not running, start! echo. start arma.bat title epochserver timeout /t 39 /nobreak >nul ) 

the problem "echo %ora%" give me result "echo off" instead value of time in seconds

what problem?

thank in advance!

you need enable delayed expansion:

tasklist /fi "imagename eq cmd.exe" /v | find /i /n "armaserver" >nul if "%errorlevel%"=="1" (   /f "tokens=1-4 delims=:.," %%a in ("%time%") (      set /a "ora=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"   )   echo percent inside ^(^)=%ora%   setlocal enabledelayedexpansion     echo exclamation=!ora!   endlocal ) echo percent  outside ^(^)=%ora% 

output:

==>d:\bat\so\30834591.bat percent inside ()= exclamation=214860 percent  outside ()=214860  ==> 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -