John said:
_winControlPanel =
System.Diagnostics.Process.Start(@"C:\windows\system32\control.exe");
_winControlPanel.Kill();
The first statement can launch COntrolPanel, but the second statement cannot
kill it.
That's because Control Panel is not a separate application. Launching
control.exe simply tells Explorer to open Control Panel, then it immediately
exits. This mere existence of control.exe is in fact a compatibility
holdover from Windows 3.1 (yes, all the way back).
I know of no reliable way of forcing the window you opened this way to close
again. Looking for the Explorer window titled "Control Panel" and closing
that will certainly *not* do it (as this name is different across different
language versions of Windows).
I can't think of any sensible reason to open Control Panel programmatically
in the first place, but letting the user close it on their own doesn't seem
to burdensome. Otherwise, you'll have to be more precise about what you're
ultimately trying to achieve.