Getting ouput from Process.Start() in Vista
Hello!
I want to call a php-script out of a C#-Application and get the output of the php-script as result:
Code:
// Call PHP
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = sPathToPhp+"php.exe";
proc.StartInfo.Arguments = sScript + " " + sParameter;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.CreateNoWindow = true;
proc.Start();
proc.WaitForExit();
String sOutput = proc.StandardOutput.ReadToEnd();
proc.Close();
This works fine in XP, but in Vista, sOutput keeps empty - any ideas what could be wrong?
Re: Getting ouput from Process.Start() in Vista
Check if it's a permissions issue. As a test, run the app as an administrator (or if you are debugging, run Visual Studio as an admin).
Re: Getting ouput from Process.Start() in Vista
Thanks for your reply. I found out that it's because of the space in "program files" - you have to put the paramters in " to make it work.
Re: Getting ouput from Process.Start() in Vista
Quote:
Originally Posted by
martho
Thanks for your reply. I found out that it's because of the space in "program files" - you have to put the paramters in " to make it work.
But you would have to do that in XP as well...
Re: Getting ouput from Process.Start() in Vista
Thats true, but we use XP and Vista in German Versions. So in XP it's language-dependend ("Programme"), but in Vista it's "Program Files" no matter which language you have. Thats why I didn't encounter the problem in my XP.