Passing variables/arguments between programs
Posted: 13 Aug 2009 09:07
I am new to DOS/CMD programming. I am writing a script to automate the backing up of certain user files and the user state. That script calls this one, called "scanstate.cmd".
I am introducing 2 new variables:
"rerun" is used to check to make sure that scanstate.exe ran without error. If scanstate.exe errors, it returns an errorlevel=4.
"continue" is used to verify that scanstate.exe is done and return processing to the original script.
I need the values of the variables to be passed to the original script as arguments.
(I have the line "set errorlevel=4" in the code to force the subsequent If Conditional to run, for testing purposes.)
In the If conditional, "set rerun=1" doesn't seem to be working. Neither does "set continue=1".
What am I doing wrong?
====================================
@echo on
set rerun=0
set continue=0
echo %rerun%
echo %continue%
pause
echo Enter Log In Name of User being Refreshed
set /P strAcct= User :
Set strUser=%strDomain%\%strAcct%
Start "Copying User State" /b /wait "c:\_Deployment\ScanState\scanstate.exe" c:\_Deployment\Backup /ue:*\* /ui:ent\%strAcct%
rem set errorlevel=4
if %errorlevel% == 4 (
set rerun=1
echo %rerun%
echo Scanstate failed. Restarting scan.
rem del c:\_Deployment\Backup\* /s
Start "" /b /wait "C:\_Deployment\Backup.cmd" %rerun% %continue%
echo error level %errorlevel%
echo %rerun% %continue%
Pause
)
Set continue=1
echo %rerun% %continue%
Pause
Start "" /b /wait "C:\_Deployment\Backup.cmd" %rerun% %continue%
===============================================
Thanks,
Dave
I am introducing 2 new variables:
"rerun" is used to check to make sure that scanstate.exe ran without error. If scanstate.exe errors, it returns an errorlevel=4.
"continue" is used to verify that scanstate.exe is done and return processing to the original script.
I need the values of the variables to be passed to the original script as arguments.
(I have the line "set errorlevel=4" in the code to force the subsequent If Conditional to run, for testing purposes.)
In the If conditional, "set rerun=1" doesn't seem to be working. Neither does "set continue=1".
What am I doing wrong?
====================================
@echo on
set rerun=0
set continue=0
echo %rerun%
echo %continue%
pause
echo Enter Log In Name of User being Refreshed
set /P strAcct= User :
Set strUser=%strDomain%\%strAcct%
Start "Copying User State" /b /wait "c:\_Deployment\ScanState\scanstate.exe" c:\_Deployment\Backup /ue:*\* /ui:ent\%strAcct%
rem set errorlevel=4
if %errorlevel% == 4 (
set rerun=1
echo %rerun%
echo Scanstate failed. Restarting scan.
rem del c:\_Deployment\Backup\* /s
Start "" /b /wait "C:\_Deployment\Backup.cmd" %rerun% %continue%
echo error level %errorlevel%
echo %rerun% %continue%
Pause
)
Set continue=1
echo %rerun% %continue%
Pause
Start "" /b /wait "C:\_Deployment\Backup.cmd" %rerun% %continue%
===============================================
Thanks,
Dave