3

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.

Community
  • 1
  • 1
Atiris
  • 2,613
  • 2
  • 28
  • 42
  • The process you end up calling may actually be spawning another process to do the work. Get the PID of your Process object and compare it to what's running in the environment. e.g. with Task Manager with the PID column shown. – Paul Sasik Jul 09 '13 at 16:25
  • Thanks Paul. Someone put here easier solution. But using PID may work. Unfortunately using PID is harder for understand and implement for me. – Atiris Jul 09 '13 at 16:41
  • The solution was provided by: http://stackoverflow.com/users/1522976/pravin I thought the answer posted looked more like a comment... Needed a lot more work and explanation. – Paul Sasik Jul 09 '13 at 16:49

1 Answers1

3

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();

Atiris
  • 2,613
  • 2
  • 28
  • 42
Jack
  • 253
  • 3
  • 8
  • This should be a comment or an edit to the OP. Please delete it. Thanks. – Paul Sasik Jul 09 '13 at 16:23
  • 1
    Thanks for solution, but there is an error .. you must escape backslash (use double backslash \\) or disable escape character (\) for whole string with @ (in this part of your code: "C:\Windows\system32\rundll32.exe"). I edited your code to work. – Atiris Jul 11 '13 at 10:45