giogio Posted October 12, 2007 Posted October 12, 2007 i have an application that execute window command shell, the returned value is then processed by the application, i made a small au3 script and the output value is showed by: Msgbox(1,"my value is: ",$Output). The question is; 1) how to to run my exe script from the window command shell and return the value to the shell? Many thanks for your help By
PsaltyDS Posted October 12, 2007 Posted October 12, 2007 (edited) i have an application that execute window command shell, the returned value is then processed by the application, i made a small au3 script and the output value is showed by: Msgbox(1,"my value is: ",$Output). The question is; 1) how to to run my exe script from the window command shell and return the value to the shell? Many thanks for your help By If the value is numeric and fits in a 32bit DWORD, you can just use it as a parameter on EXIT: If @error Then Exit 1234567 Else Exit 0 EndIf It will show up in the command shell as %ERRORLEVEL%. Edit: typo Edited October 12, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
giogio Posted October 12, 2007 Author Posted October 12, 2007 i made a test.exe this is the script: If @error Then Exit 0 Else Exit 12321 EndIf then i execute it from window using: cmd.exe /C c:\test.exe no result. were i am wrong?
PsaltyDS Posted October 12, 2007 Posted October 12, 2007 (edited) i made a test.exe this is the script: If @error Then Exit 0 Else Exit 12321 EndIf then i execute it from window using: cmd.exe /C c:\test.exe no result. were i am wrong? Well, to get a result, you would have to run from a command line manually or via a batch file and do something like this: C:\Test.exe echo %ERRORLEVEL% But something seems to have changed. I compiled a one line script from this: Exit 1oÝ÷ Ø Ý§"»§¶Åçë¢f¢iÙbæ§vØ^ç! DQ9ÄT² zݽêò¶)"ÇÚz¶)à¢yr¶¬µ«n²ØZ¶Ø^r©Wëh"اµêéë^®+)æ¬yÜ"¶±é_jwg¢ÛayÊ&©Ýy×±×(uâ7öjkzÛr²êÞ¶ºÇ¶(®K§²êÞØ!Ê'~*æyØÁ«#ºËmè§µêéë^¯l²ÖºÆò~Üx-ç(¥zÚnº$z{®*mjëh×6Exit _DingleBerry() When I run the .exe, it pops the expected error message, the returns 2 for %ERRORLEVEL%. So we are only getting the AutoIt interpreter's status code, not the parameter from 'Exit'. Edited October 12, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
PsaltyDS Posted October 13, 2007 Posted October 13, 2007 (edited) Figured out my confusion, which I think I had figured out before (like a year or more ago), but this is not something I do every day and it was forgotten.The basic problem is that the shell environment of the CMD console, and the shell environment of a running batch file (.bat or .cmd) are NOT the same.If you run a compiled AutoIt script MANUALLY from the command line, by typing in "Test.exe" and hitting enter, then typing in "echo %ERRORLEVEL%" and hitting enter again, you only get the return code of the spawned windows environment that runs the executable, which in the case of a compiled AutoIt script is the exit code from the AutoIt interpreter, not the script's "Exit (123)" function. That is what I was doing in the above post.If you create an actual batch file like this:C:\Temp\Test.exe echo Return code was %ERRORLEVEL%Then run the batch file and you get the actual parameter passed to the Exit function in the AutoIt script.Some things are just different inside the shell of a batch file. Remember, for example, that with a DOS command line like this:FOR /L %i IN (2, 2, 10) DO ECHO Even numbers: %iYou have to double up the '%' on variable references inside a batch file but not when typing at the console:FOR /L %%i IN (2, 2, 10) DO ECHO Even numbers: %%iSo AutoIt's "Exit (1234567)" will behave as expected inside an actual batch file, but not when using manual commands at the console. P.S. This doesn't address the original point about how to send TEXT to CMD shell environment that runs your compiled script. 'Exit (n)' can only return a signed 32bit integer. Edited October 13, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
paulobnu Posted March 27, 2013 Posted March 27, 2013 To return a text message to prompt you need to convert your code AU3 for DOS, using the program Aut2exe.exe. Thus the function ConsoleWrite sends message to the terminal.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now