thepip3r Posted October 6, 2010 Share Posted October 6, 2010 I know you can use @error to test for errors but is there a way to check for the returned error of the command you passed to the host OS? similar to if err.number <> 0 then msgbox err.description in vbscript? sorry, i'm sure this is a noob question. My Additions:- RunAs AdminDeviant Fun:- Variable Sound Volume Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 6, 2010 Share Posted October 6, 2010 Perhaps you mean the returned %ERRORLEVEL% from RunWait()? See help file. 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 Link to comment Share on other sites More sharing options...
thepip3r Posted October 6, 2010 Author Share Posted October 6, 2010 could you please be more specific? I've looked through the functions, macros, and keywords and a number of other locations in the documentation and am not able to locate this %ERRORLEVEL% you speak of: http://www.autoitscript.com/autoit3/docs/functions/RunWait.htm My Additions:- RunAs AdminDeviant Fun:- Variable Sound Volume Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 6, 2010 Share Posted October 6, 2010 You were not specific about what "command you passed to the host OS" meant. This was the simple example I was talking about: $iRET = RunWait(@ComSpec & ' /c DIR "C:\NoSuchDir"') ConsoleWrite("$iRET = " & $iRET & @LF) It returns 1 because DIR on a non-existing directory returns %ERRORLEVEL% = 1 to the shell. If you meant a call to a COM object, then you want COM/OBJ Reference in the help file, with attention to COM Error Handlers. 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 Link to comment Share on other sites More sharing options...
thepip3r Posted October 7, 2010 Author Share Posted October 7, 2010 (edited) You were not specific about what "command you passed to the host OS" meant. This was the simple example I was talking about: $iRET = RunWait(@ComSpec & ' /c DIR "C:\NoSuchDir"') ConsoleWrite("$iRET = " & $iRET & @LF) It returns 1 because DIR on a non-existing directory returns %ERRORLEVEL% = 1 to the shell. If you meant a call to a COM object, then you want COM/OBJ Reference in the help file, with attention to COM Error Handlers. right and i understand that typically functions return 0 on success, 1 on failure. what i was looking for was something equivalent to the vbscript err object. where: if @error then msgbox(0,"Error Occurred", err.description); endif ...so if you pass a path to the run or exec command and the path isn't valid, err.description would report back "invalid path" or "path not found". this may be strictly a vbscript available object but that's what i was looking for. Edited October 7, 2010 by thepip3r My Additions:- RunAs AdminDeviant Fun:- Variable Sound Volume Link to comment Share on other sites More sharing options...
thepip3r Posted October 7, 2010 Author Share Posted October 7, 2010 disregard: http://www.autoitscript.com/autoit3/docs/functions/StderrRead.htm My Additions:- RunAs AdminDeviant Fun:- Variable Sound Volume Link to comment Share on other sites More sharing options...
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