.cmd file help
I need to create a .cmd file that executes two items...
First a .bat file and second a .exe file
The .bat file must complete successfully (return code zero) for the .exe to start.
I have close to no experience creating .cmd files or batch files. If anyone could help me out or point me in the right direction for a tutorial how to do this, that would be great. Thanks in advance. Sorry if this is the wrong forum, wasn't sure where to put it.
[474 byte] By [
btisdabomb] at [2007-11-19 23:56:49]

# 3 Re: .cmd file help
Right, but if the .bat command returns an error then I don't want to run the .exe
Here is what I have come up with... If you see something wrong with it let me know as I haven't ever created a .cmd file before.
REM *************** Execute PrepareTables_SnDataPersistor ***********************
Set ReturnCode=0
CALL dsp_Dist_PrepareTables.bat
Set ReturnCode=%ErrorLevel%
If %ReturnCode% == 0 GoTo SnDataPersistor
Set ReturnCode=99
Goto End
:SnDataPersistor
START SlnDataToCMGPersistor.exe
If %ReturnCode% == 0 GoTo End
Set ReturnCode=99
Goto End
:End
Exit
# 5 Re: .cmd file help
I can't get this to work right...
I have modified my file to log what is happening.
Here is what I have
REM *************** SalesNEtDRPersistor.cmd ***********************
Set ReturnCode=0
REM ********* change the following Drive= to reference a log file from where the logfile should be written
Set Drive=d:\apps\SalesNet\SalesnetToCMG\CMGPersistor\Log\
Set Logfile=%Drive%SalesNetDRPersistor.log
echo *************** SalesNetDRPersistor.cmd *********************** > %logfile%
echo **** Starting Date Time: ******** >> %logfile%
echo %Date% %Time% >> %logfile%
echo ********************************* >> %logfile%
CALL D:\apps\SalesNet\SalesnetToCMG\CMGPersistor\dsp_Dist_PrepareTables.bat
echo *************** .bat ErrorLevel *********************** > %logfile%
Set ErrorLevel=%ReturnCode%
echo %ErrorLevel%
If %ReturnCode%==0 Goto SnDP
Set ReturnCode=99
Goto End
:SnDP
echo *************** Starting SlnDataToCMGPersistor.exe *********************** > %logfile%
echo **** Starting Date Time: ******** >> %logfile%
echo %Date% %Time% >> %logfile%
echo ********************************* >> %logfile%
CALL D:\apps\SalesNet\SalesnetToCMG\CMGPersistor\SlnDataToCMGPersistor.exe
If %ReturnCode%==0 Goto End
echo *************** ERROR *********************** > %logfile%
echo **** Ending Date Time: ******** >> %logfile%
echo %Date% %Time% >> %logfile%
echo ********************************* >> %logfile%
Set ReturnCode=99
Goto End
:End
echo *************** FinishTime *********************** > %logfile%
echo **** Ending Date Time: ******** >> %logfile%
echo %Date% %Time% >> %logfile%
echo ********************************* >> %logfile%
Exit
After it calls D:\apps\SalesNet\SalesnetToCMG\CMGPersistor\dsp_Dist_PrepareTables.bat, it stops. The log from dsp_Dits...bat shows that it is executing and has a ReturnCode of 0
Any ideas why it stops after that?