legendjr
legendjr

Reputation: 276

Can I pass an error message from a C# executable out into a VBScript

I have a C# command executable I created. In it, I have built some error handling. I would like to be able to pass these thrown errors out of the program into another script that the users will have control over (in VBS). I have seen I can set the Environment.Exit integer, but can I send my error message?

Upvotes: 0

Views: 47

Answers (1)

Ansgar Wiechers
Ansgar Wiechers

Reputation: 200373

As @SLaks mentioned: write the error message to STDERR. If you run your executable via the Exec method you can get the exit code and error message like this:

Set ex = CreateObject("WScript.Shell").Exec("C:\path\to\your.exe")

While ex.Status = 0
  WScript.Sleep 100
Wend

exitcode = ex.ExitCode
errormsg = ex.StdErr.ReadAll

Upvotes: 1

Related Questions