Modify

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#2092 closed Bug (No Bug)

ShellExecuteWait() receiving incorrect error levels on Windows XP.

Reported by: Daniel_Freer@… Owned by:
Milestone: Component: AutoIt
Version: 3.3.6.1 Severity: None
Keywords: ShellExecuteWait, error level, exit code Cc:

Description

Description: Executing a file through ShellExecuteWait() will result in incorrect error levels (exit codes) on Windows XP only. Windows 7/Vista appear to be unaffected.

Steps to reproduce:
(1). Create a batch file to produce an exit code.

@ECHO OFF
REM error.bat
REM Exits with the first argument as an exit code.
Exit /B %1 

(2). Execute batch file in Command Prompt, then check error level.

C:\> error.bat 5
C:\> echo %errorlevel%
5

(3). Execute batch file using AutoIt/ShellExecuteWait, then check error level on Windows XP.

$errorlevel = ShellExecuteWait("C:\error.bat", 5)
MsgBox(64, "Error Level", $errorlevel)

Expected Results:
5

Actual Results:
0 or 1

Attachments (0)

Change History (3)

comment:1 by J-Paul Mesnage, 14 years ago

Same with 3.3.8.0
It needed to check with latest Beta/release in case of

comment:2 by trancexx, 14 years ago

Resolution: No Bug
Status: newclosed

This is not bug on our side. AutoIt is correct about return value.
What you should do is try exit batch without /B flag. This looks like cmd.exe bug on XP.

Oh yes and... if you want to run batch file then don't use ShellExecute functions, use Run functions so that you know for sure what will happen.

comment:3 by Daniel_Freer@…, 14 years ago

Workaround:
Use the RunWait function (Run doesn't return error levels directly). /B flag doesn't appear to influence the outcome in any way.
Modify Step 3 as follows:

$errorlevel = RunWait(@ComSpec & " /c " & 'C:\error.bat 5')
MsgBox(64, "Error Level", $errorlevel)

Expected Results:
5

Actual Results:
5

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.