Modify

Opened 12 years ago

Closed 12 years ago

Last modified 12 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 Changed 12 years ago by Jpm

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

comment:2 Changed 12 years ago by trancexx

  • Resolution set to No Bug
  • Status changed from new to closed

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 Changed 12 years ago by Daniel_Freer@…

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

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.