Active Member
  
Group: Members
Posts: 47
Member No.: 1386
Joined: 22-July 05

|
hi shoorick my batch files something looks like below. The script is running from MSDOS real mode and would call test.exe. Test.exe will simply return whatever the parameter on the command line typed on the (2 in this example). Source code is pasted after the batch file content. I thought the script will capture that returned value at errorlevel 2 and goto err2 label. That is my expectation.
I know the errorlevel statements are correct because if I replace test.exe 2 call with choice /c:1234 menu than it correctly captures the keyboard input and goes to the correct label. Thanks!
=========== batch file content ===========
test.exe 2 if errorlevel 4 goto err4 if errorlevel 3 goto err3 if errorlevel 2 goto err2 if errorlevel 1 goto err1
:err4 :goto end
:err3 :goto end
:err2 :goto end
:err1 :goto end
:end
=========== test.exe source. ===========
ASSUME CS:CODE, DS:DATA, SS:STACK, ES:NOTHING Main PROC NEAR
; Initialize segment registers.
mov ax, ds mov es, ax ; (ES) = save PSP in ES.
mov ax, DATA mov ds, ax ASSUME DS:DATA
mov ax, STACK mov ss, ax ASSUME SS:STACK
; Grab a command line switch from PSP.
mov bp, 82h mov al, byte ptr es:[bp] mov ah, 04ch ; (AH) = terminate process fcn code. int 21h ret Main ENDP
|