473,397 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

how to close the window generated by an process(for msinfo32) after it exits

Hi.
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
  1. using System.Diagnostics;
  2. ......
  3.  
  4. Process processInstance = new Process();
  5. processInstance.StartInfo.FileName = "msinfo32";
  6. processInstance.Start();
  7.  
  8. //some other processing goes on here during which this process exits.
  9. //I have used Thread.Sleep to simulate the condition.
  10. Thread.Sleep(10000);
  11.  
  12. //both of these give exception
  13. processInstance.Kill();  //OR
  14. processInstance.CloseMainWindow();
  15.  
  16. //this works fine but the system information window remains open.
  17. processInstance.Close();
  18.  

Thanks for help in advance.
ParagS.
Mar 14 '08 #1
2 1538
Plater
7,872 Expert 4TB
I would guess that when you run that process it really opens it's another process withen itself?
Like you run process A, and processAs only job is to (secretly?) open processB.
ProcessB is the window you see, but you only have control to close processA.

You might have to do a Process.GetAllProccess() (or whatever) and find the one you want and kill it that way?
Mar 14 '08 #2
Thanks for your help plater.

It works in the way you explained. It starts HelpCtr.exe process internally.
I closed it explicitly and I am done.
Mar 17 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Lei Guangfu | last post by:
Hi, I have a program need to check the value of a application available, and then decide whether to execute codes followed. In order to achieve this purpose, I use DO WHILE loop to judge the...
1
by: Lei Guangfu | last post by:
Hi, I have a program need to delay for a given time, I use DO WHILE loop to achieve this goal, but this method consumes too much CPU resource. So I want to find a way to pause a process for a...
1
by: jdapro | last post by:
Hi - thanks for reading this out there! I'll be quick about it: I've got this row of images (in the end there will be more rows of pics as well). When a user clicks on the image, I want a new...
2
by: lovecreatesbeauty | last post by:
Hello experts, When I allocate memory use malloc() and forget to call a corresponding free(), does this allocated memory lose forever after program exits (Can i regard it same as process...
2
by: Chan | last post by:
If i call invalidate() two times, how can I stop the process for some time between them? that is, do updating ----> invalidate() -->do updating----> pause--> invalidate() I update my data in my...
3
by: Eric | last post by:
I want to create a pop up window for printing report, but I encounter some problem. (1). If use showModalDialog, then the toolbar of the browser is missing, can i display the print toolbar for...
0
by: Elton W | last post by:
Hi Peter, You use DeleteButton.Attributes.Add("onclick", "return confirm ('Are you sure you want to delete?');"); in datagrid_ItemDataBound event to add confirmation for delete button.
10
nathj
by: nathj | last post by:
Hi, I have a quick favour to ask - would someone please check over this concept for me? Basically I need to generate a login script and while time is on my side I want to invest in writing my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.