joeloyzaga Posted May 4, 2012 Share Posted May 4, 2012 I can run from scite but when I run from exe I want to return an error code - (being somewhat a novice) I don't have a clue where to start Joe Link to comment Share on other sites More sharing options...
MilesAhead Posted May 4, 2012 Share Posted May 4, 2012 See Exit in the help. My Freeware Page Link to comment Share on other sites More sharing options...
Skitty Posted May 4, 2012 Share Posted May 4, 2012 (edited) expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Compression=0 #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ProcessConstants.au3> Global $ChildPID Global $temporariis Global $Datum If $CmdLine[0] Then Sleep(1000) Exit(9001) EndIf Switch @Compiled Case True $ChildPID = Run(FileGetShortName(@ScriptFullPath) & " test") Case False $ChildPID = Run(FileGetShortName(@AutoItExe) & ' /AutoIt3ExecuteScript "' & @ScriptFullPath & '" test') EndSwitch $Datum = DllCall("KERNEL32", 'int', 'OpenProcess', 'int', $PROCESS_QUERY_INFORMATION, 'int', False, 'int', $ChildPID) While ProcessExists($ChildPID) Sleep(100) Beep(500,100) WEnd Beep(1000,100) $temporariis = DllCall('KERNEL32', 'int', 'GetExitCodeProcess', 'ptr', $Datum[0], 'dword*', 0) DllCall('KERNEL32', 'ptr', 'CloseHandle', 'ptr', $Datum[0]) If $temporariis[0] Then MsgBox(0,"Error Code",$temporariis[2]) Else MsgBox(16,"Error!","Could not get your exit code.") EndIf You can take code from this to get the error code from a script, set the error code like exit 1 or exit(1). Edit: fixed an error I made... Edited May 4, 2012 by ApudAngelorum Link to comment Share on other sites More sharing options...
MilesAhead Posted May 6, 2012 Share Posted May 6, 2012 (edited) Depends what you need the child program to do. If you just need to run another program from a console app, and get the exeit code, you can use ShellExecuteWait(). The exit code is the return value. It may be different for Gui apps. I'm not sure. For example this program runs another that recursively copies files. The slave program cannot write to the console without being weird about it(it's an AHK app) so I have it exit with the code as the number of files copied. The launching program is an AutoIt console app. The last 2 lines are $result = ShellExecuteWait($slavePath, $CmdLineRaw) ConsoleWrite($result & " File(s) Copied") The launcher just passes on it's command tail raw to the slave app, and waits for the count of copied files. Many ways to skin the cat. Edited May 6, 2012 by MilesAhead My Freeware Page Link to comment Share on other sites More sharing options...
ur Posted October 11, 2015 Share Posted October 11, 2015 If I want to send exit code back to the parent program or any string data from my autoit compiled exe.How to do that.Hope you understand, my situation is reverse case to this question. Link to comment Share on other sites More sharing options...
AutoBert Posted October 11, 2015 Share Posted October 11, 2015 RunWait and ShellExecute returning the ExitCode after child has ended. Link to comment Share on other sites More sharing options...
ur Posted October 21, 2015 Share Posted October 21, 2015 RunWait and ShellExecute returning the ExitCode after child has ended.No, the case is reverse here.THe child process is our code and how to return values to any other third party parent process like the one written in c#. Link to comment Share on other sites More sharing options...
JohnOne Posted October 21, 2015 Share Posted October 21, 2015 Exit ($errorcode) AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
ur Posted December 15, 2017 Share Posted December 15, 2017 On 10/21/2015 at 3:04 PM, JohnOne said: Exit ($errorcode) I tried getting the error code using this. Not working. Link to comment Share on other sites More sharing options...
careca Posted December 15, 2017 Share Posted December 15, 2017 (edited) Wow from 2012 to 2015 to now. Ur the ressurector! Edited December 15, 2017 by careca Earthshine 1 Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
Developers Jos Posted December 15, 2017 Developers Share Posted December 15, 2017 3 hours ago, ur said: I tried getting the error code using this. Not working. You are not trying hard enough nor providing any information. Please stop posting here until you have something to show for! Jos Earthshine 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Recommended Posts