Sign in to follow this  
Followers 0
thepip3r

VBScript -> AutoIT Error Handling Help

6 posts in this topic

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

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by thepip3r

My Additions:- RunAs AdminDeviant Fun:- Variable Sound Volume

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