问题
Is there any possibility to open Internet Properties window..
Code:
System.Diagnostics.Process p;
p = System.Diagnostics.Process.Start("InetCpl.Cpl", ",4");
..and wait until user close it? (and then check internet connection and continue)
This code not work:
p.WaitForExit();
I think this problem is related to Open explorer window and wait for it to close but solution for this contains only tips specific for windows explorer browser window.
Can I do this in C#?
Solution
Someone put here (only for a short moment) this full command how to open Internet Properties window:
C:\Windows\system32\rundll32.exe C:\Windows\system32\shell32.dll,Control_RunDLL C:\Windows\system32\inetcpl.cpl,,4
I tried it .. and really .. it works!
System.Diagnostics.Process p;
p = System.Diagnostics.Process.Start("rundll32.exe",
@"C:\Windows\system32\shell32.dll,Control_RunDLL"
+ " C:\Windows\system32\inetcpl.cpl,,4");
p.WaitForExit();
MessageBox.Show("Properties closed");
I get "Properties closed" message only after I close Properties window.
No PID needed .. easy and perfectly elegant solution.
If the user that wrote the original response with this command write it again, I accept his solution.
回答1:
Use the below Code to open control panel in separate process:
System.Diagnostics.Process.Start(@"C:\Windows\system32\rundll32.exe"
, @"C:\Windows\system32\shell32.dll,Control_RunDLL"
+ " C:\Windows\system32\inetcpl.cpl,,4");
and then you can WaitForExit();
来源:https://stackoverflow.com/questions/17553209/open-internet-properties-and-wait-until-user-close-it-c-sharp