-2
      System.Diagnostics.ProcessStartInfo procStartInfo =
                new System.Diagnostics.ProcessStartInfo("C://test.exe", "/c ");
              procStartInfo.RedirectStandardOutput = true;
            procStartInfo.UseShellExecute = false;
            procStartInfo.CreateNoWindow =true;                                       System.Diagnostics.Process proc = new System.Diagnostics.Process();
               proc.StartInfo = procStartInfo;
               proc.Start();      
                foreach (Process p in Process.GetProcesses())
            {

                if (p.ProcessName == "test.exe")
                {
                    p.Kill();
                }

This code opens my exe and runs in background. But i didnt get the required output. And its not getting closed also. (functionally My exe should open and read two text files and generates some values on an output text file.)

  • http://stackoverflow.com/questions/1137781/c-sharp-correct-way-to-load-assembly-find-class-and-call-run-method – Maria Ines Parnisari Oct 22 '14 at 04:33
  • There is little point in trying to hide a process. Your user can always "access" it, it is visible in Task Manager and the user can kill it whenever he feels that something odd is happening on his machine. The standard way to incorporate native code in your C# project is by creating a C++/CLI class library project. Short from solving the creepy hidden process issue, it will make your program a lot more reliable. Detecting and reporting misbehavior in another process is not simple. – Hans Passant Oct 22 '14 at 06:20

1 Answers1

0

Have you tried something like this?

ProcessStartInfo ProcessInfo = new ProcessStartInfo(PathToExe, MyArgs);
ProcessInfo.CreateNoWindow = true;
ProcessInfo.WindowStyle = ProcessWindowStyle.Hidden;
Process MyProc = Process.Start(ProcessInfo);
MyProc.WaitForExit();
Steve Wellens
  • 20,506
  • 2
  • 28
  • 69