>I didn't use Wait-Process below because I want the exit value.

Did someone say exit code?

$Args = New-Object System.Collections.ArrayList
    [void]$Args.Add("--Bad-Arg")
$Process = New-Object System.Diagnostics.Process
$Process.StartInfo.UseShellExecute = $false
$Process.StartInfo.RedirectStandardOutput = $true
$Process.StartInfo.RedirectStandardError = $true
$Process.StartInfo.FileName = "C:\Windows\System32\ipconfig.exe"
$Process.StartInfo.Arguments = $Args
[void]$Process.Start()
$Process.WaitForExit()
$ExitVal = $Process.ExitCode
$StdOut = $Process.StandardOutput.ReadToEnd()
$StdErr = $Process.StandardError.ReadToEnd()

$ExitVal
$StdOut

--------------

1

Error: unrecognized or incomplete command line.
/snip


~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin

Reply via email to