How to trap an error from a shelled process in c#
ive been using this site for a while and have my first question to ask - as the help here is awesome.
Im writing a c# dll (for use in VbScript) and in that DLDL im shelling out a command and wish to trap the return code of that command. So far I have the following c# code:-
public int InstallHotfix(String strAppName,string strExe,string strParam)
{
ProcessStartInfo startInfo = new ProcessStartInfo(strExe,strParam);
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(startInfo);
}
I am calling this from a VB script but would like to know how to return the result back to VBS. I assume there a 'return' value that I have to enter but im unsure how to ach开发者_C百科ieve this.
Cheers.
ProcessStartInfo startInfo = new ProcessStartInfo(strExe, strParam);
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
Process proc = Process.Start(startInfo);
proc.WaitForExit();
int exitCode = proc.ExitCode;
精彩评论