WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

DOS

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Dos errorlevel return code

Keywords: 	 Dos error level return code 

Question:

IS there a way within winbatch to retrieve the dos errorlevel code returned from a failed commandline (am using "runhidewait"). The reason I ask, I would rather use winbatch to start a database backup of an interbase DB the easiest way is to run their commandline util called gbak.exe if the backup fails for whatever reason I would like to write this to a log file so I know the backup failed otherwise winbatch just appears that all is well. Below is the sample code.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Interbase backup routine
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ISC_USER = "SYSDBA"
ISC_PASSWORD = "masterkey"
LiveDB = '"C:\Program Files\Internet Manager\Data\common.gdb"'
DBDir = "C:\temp\Backup"
BackupDB = "%DBDir%\common.bak"

If !DirExist(DBDir) Then DirMake(DBDir)

DirChange("c:\temp")
B = RunHideWait(Environment("COMSPEC"), '/c gbak.exe -user %ISC_USER% -Pas
%ISC_PASSWORD% -backup %LiveDB% %BackupDB%')

If b != @TRUE
c = "Gbak not found"
EndIf

A = LastError()

Message("Complete", "Last error was %a% or %c%")
; CrtFil = FileOpen("c:\temp\Error.log", "WRITE")
;FileWrite(CrtFil, b)
;FileClose(CrtFil)
Any suggestions?

Answer:

Use:
errorlevel=IntControl(64,0,0,0,0)

Article ID:   W15139
File Created: 2004:05:25:13:31:56
Last Updated: 2004:05:25:13:31:56