CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 1999
    Location
    Germany
    Posts
    2,338

    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?

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    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).

  3. #3
    Join Date
    Aug 1999
    Location
    Germany
    Posts
    2,338

    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.

  4. #4
    Join Date
    Jun 2008
    Posts
    2,477

    Re: Getting ouput from Process.Start() in Vista

    Quote Originally Posted by martho View Post
    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...

  5. #5
    Join Date
    Aug 1999
    Location
    Germany
    Posts
    2,338

    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.
    Last edited by martho; August 12th, 2009 at 03:31 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured