Jump to content

Passing %ERRORLEVEL% from AutoIt to Vista


Recommended Posts

I'm using AutoIt to write a portion of our logon script. I need to determine the OS for logic in the batch file we run at logon.

AutoIt code to set the $OSCode variable is as follows:

*******************************************

If @OSVersion = "WIN_2000" Then

$OSCode = 50

ElseIf @OSVersion = "WIN_XP" Then

$OSCode = 60

ElseIf @OSVersion = "WIN_VISTA" Then

If @OSArch = "X64" Then

$OSCode = 72

ElseIf @OSArch = "X86" Then

$OSCode = 70

EndIf

Else

$OSCode = 99

EndIf

*******************************************

When done, I exit the AutoIt script using this line:

*******************************************

Exit ($OSCode)

*******************************************

which passes the %ERRORLEVEL% value to the batch file. Or is SUPPOSED to.

Here's the problem:

In XP, when I echo %ERRORLEVEL% in my batch file, I get '60' displayed, as I should. Everything works perfect.

In Vista 32-bit or 64-bit, when I echo %ERRORLEVEL% in my batch file, I get '0'. The logic in the batch file fails due to the zero being returned.

When I run the compiled AutoIt script on Vista, it returns the proper OS Code (70 or 72, depending on 32-bit or 64-bit Vista.) But passing the %ERRORLEVEL% is failing in all versions of Vista.

Anyone got any ideas?

Link to comment
Share on other sites

The AutoIt portion is working. When I run the compiled .exe on Vista 32 or Vista 64 it returns the proper value-70 or 72. It's just when passing THAT value back to the batch file that Vista seems to be losing it, and is resetting the %ERRORLEVEL% back to the default of zero.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...