Jump to content

Recommended Posts

Posted

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

Posted

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

Posted

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
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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...