Sign in to follow this  
Followers 0
MrChris

Getting Returncode from runwait and sending it to MsgBox

3 posts in this topic

#1 ·  Posted (edited)

What is the best way I could get the Output of an Errorlevel/returncode if the return code is anything other than a 0 and send the output of what is displays to a msgbox? I have a few commands I am running from a command line via RunWait like below. If there is an error when processing the bwlow commands I was hoping I could see the actual error without setting @SW_SHOW.

Rather than just getting the Return Code I was hoping to get an actual Error message that the RunWait line may give sent to a MSGBOX.

This is what I have been able to come up with.

#NoTrayIcon
Opt("RunErrorsFatal", 0)

; Adds User to the local copmuters Account NT database
RunWait('net user /add Support /comment:"Built-in account so IT can administer the computer" /fullname:"Local IT Administrator" /times:all /expires:never /active:yes /workstations:*',"",@SW_HIDE)
if @error <> 0 Then
    MsgBox(1024,"Error Creating Account","There was an Error creating the new User Account." & @CRLF & "The error code returned was : " & @error )
EndIf

; Adds user to Local Administrators Account
RunWait("net localgroup administrators /add Support","",@SW_HIDE)
if @error <> 0 Then
    MsgBox(1024,"Error Setting Permissions","There was an Error setting the user permissions." & @CRLF & "The error code returned was : " & @error )
EndIf

Exit

Thanks for any help,

MrChris

Edited by MrChris

Share this post


Link to post
Share on other sites



Sorry I used the wrong Subject for this I meant to have it say "Get Output of Error Message and send it to a MSGBOX" if that makes it any eiser?

MrChris

Share this post


Link to post
Share on other sites

Aparently that is what "StderrRead" and "StdoutRead" are for. :P

Everytime I learn something new in AutoIT I end up diggin it that much more.

MrChris

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