Sign in to follow this  
Followers 0
ShawnLuo

How to get return value from *.exe file?

10 posts in this topic

Hi, all,

AutoIt can compile au3 file to *.exe. My question is if the *.exe file can return a value?

and if can, how to get the return value?

I found someone says use @exitcode, but I still don't know how it works. that will be very nice if you can give me a example.

thank you so much! ;)

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Hi, all,

AutoIt can compile au3 file to *.exe. My question is if the *.exe file can return a value?

and if can, how to get the return value?

I found someone says use @exitcode, but I still don't know how it works. that will be very nice if you can give me a example.

thank you so much! ;)

A return value exe to exe ?

At the end of first exe, it run second exe with parameters, that second exe can get by $cmdlines Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

Here a small example:

#AutoIt3Wrapper_OutFile=Test.exe
#AutoIt3Wrapper_Change2CUI=y
$msg = MsgBox(4, "Return Code", "Give Exit Code true back?")
If $msg = 6 Then
    Exit(1)
Else
    Exit(0)
EndIf

Here the cmd code:

@echo off
test.exe
echo %errorlevel%

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Here a small example:

#AutoIt3Wrapper_OutFile=Test.exe
#AutoIt3Wrapper_Change2CUI=y
$msg = MsgBox(4, "Return Code", "Give Exit Code true back?")
If $msg = 6 Then
    Exit(1)
Else
    Exit(0)
EndIf

Here the cmd code:

@echo off
test.exe
echo %errorlevel%

Br,

UEZ

Thanks a lot, your return value can see it cmd window, but how can I get it(the return value) in my autoit script?

Share this post


Link to post
Share on other sites

I cannot follow you! Your script produces the exit code and you want to pipe it back to your script? That makes not sense!

But you can use $cmdline variable to use parameter for your exe -> see Command Line Parameters in help file.

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Thanks a lot, your return value can see it cmd window, but how can I get it(the return value) in my autoit script?

Like this...

; The first exe
Run ( @ScriptDir & '\Second.exe ' & $_Parameterl & ' ' & $_Parameter2 )

; The second exe
If @Compiled Then
    If $CmdLine[0] < 2 Then Exit
    $_Parameterl= $CmdLine[1]
    $_Parameter2= $CmdLine[2]
EndIf

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

Simply only the caller can see the exit code of the your script because no code is run after the exit command.

You can have an AutoIt script call another then look at the exit code if you really must.

If you are attempting to do error handling there are other ways of doing this.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
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
Sign in to follow this  
Followers 0