How to return value from exe and capture the returned value using C#
I have an exe (I have the C# code for that also). I am invoking the exe in my vbscrip开发者_如何学JAVAt application. Then I want to return a value from the exe and capture the value in my vbscript code. How can I do that?
Dim WshShell, oExec
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("csharpprocess.exe")
Do While oExec.Status = 0
WScript.Sleep 100
Loop
WScript.Echo oExec.ExitCode
Reference:
http://msdn.microsoft.com/en-us/library/2f38xsxe%28VS.85%29.aspx
http://msdn.microsoft.com/en-us/library/za76z6hh%28v=VS.85%29.aspx
To return a number from the EXE file, set this value in your C# code before you exit it.
Environment.ExitCode = MyNumber;
精彩评论