-1

Because I am doing certain tasks that need the control panel to be closed if it is open. Killing explorer is not the solution I am looking for as it is also closes the file explorer. I need a general solution that will work across different system languages. Will help if the solution is a c# code.

I have already tried closing control panel using window.close() which will work if the system language is English (I cannot compare title=="Control panel" because if the system language is suppose German, then control panel is called something different), as I am doing window.title == "Control Panel". This is not a solution. I need some way to close it that will work on all systems.

halfer
  • 19,824
  • 17
  • 99
  • 186

2 Answers2

0

Try using the shell to run a command line such as:

taskkill control.exe
סטנלי גרונן
  • 2,917
  • 23
  • 46
  • 68
-1

You may need to do a lil magic to do this.

You may need to first check the system language:

CultureInfo.CurrentCulture

and keep a list of strings that match "control panel" in all (or the most likely) languages in a collection, then do the compare for the window title in the matching language.

As far as actually closing the Control Panel once you have the match, since the Control Panel is actually part of Explorer.exe, killing it's process my have undesired consequences. However, (and it may be a bit ugly to the user) if you SendKeys the equivalent of Alt + F4 to that window, it'll close just that window.

This is just one idea; WM_CLOSE may or may not work as well, rather than the SendKeys idea.

J. Scott Elblein
  • 4,013
  • 15
  • 58
  • 94