Jump to content

@Error Return on runwait(@Comspec***


Recommended Posts

I am trying to write a script that runs a DOS command from an input box.

The user types into the input box what they want to run, then clicks OK. it will then run that command by doing the following

opt("RunErrorsFatal", 0)
$Command = InputBox("DOS-Command", "Input the command to run", "", " M", 240, 180)
RunWait(@Comspec & " /k " & $Command, @TempDir)
if @error = 1 then MsgBox(0, "Error", "Unable to run the command")

The @error never returns anything but 0 no matter what I put in for the $Command. I am assuming the RunWait thinks it was successfull because the @Comspec launched but the actual command failed.

Does anyone know of a way to return an error=1 if the command fails?

Thanks,

Mike

Link to comment
Share on other sites

  • Developers

I am trying to write a script that runs a DOS command from an input box.

The user types into the input box what they want to run, then clicks OK.  it will then run that command by doing the following

opt("RunErrorsFatal", 0)
$Command = InputBox("DOS-Command", "Input the command to run", "", " M", 240, 180)
RunWait(@Comspec & " /k " & $Command, @TempDir)
if @error = 1 then MsgBox(0, "Error", "Unable to run the command")

The @error never returns anything but 0 no matter what I put in for the $Command.  I am assuming the RunWait thinks it was successfull because the @Comspec launched but the actual command failed.

Does anyone know of a way to return an error=1 if the command fails?

Thanks,

Mike

<{POST_SNAPBACK}>

The Runwait command returns the exit code so use it like:

$rc = Runwait()
If $rc = 0 then
  ; do whatever
endif

or

If Runwait() then
  ; do whatever when rc not equal 0
endif

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

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
 Share

  • Recently Browsing   0 members

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