I am trying to open a process for msinfo32.exe using C#.
I successfully started it.
But after that I need to wait for 10 seconds for some other operations during which this process gets exited.
After this, I want to close the "System Information" window generated by this process.
I tried using processInstance.CloseMainWindow(), but I get the exception as "No process associated with this object".
The code snippet is :
Expand|Select|Wrap|Line Numbers
- using System.Diagnostics;
- ......
- Process processInstance = new Process();
- processInstance.StartInfo.FileName = "msinfo32";
- processInstance.Start();
- //some other processing goes on here during which this process exits.
- //I have used Thread.Sleep to simulate the condition.
- Thread.Sleep(10000);
- //both of these give exception
- processInstance.Kill(); //OR
- processInstance.CloseMainWindow();
- //this works fine but the system information window remains open.
- processInstance.Close();
Thanks for help in advance.
ParagS.