-1

I need to open a Control Panel windows with a const search string: date directly.

Like this:

Control panel with search string

Is there any way to save a control.exe search result and reuse it as we does inside the explorer.exe to do this job?

Or any other ways are all acceptable.

Just give me a guidance, specific codes are not necessarily.

hyzhangzhy
  • 17
  • 3
  • ask this on Microsoft's forum as well. – Masoud Andalibi Jan 18 '17 at 08:59
  • Thanks, post it [here](https://social.msdn.microsoft.com/Forums/en-US/c757c301-6f2c-4238-aa99-1d05b45359bb/is-there-any-way-to-open-a-control-panel-windows-with-search-string-programmly?forum=windowsdesktopsearchdevelopment) on msdn. – hyzhangzhy Jan 18 '17 at 09:29

1 Answers1

1

I tried some ideas in the past minutes, so I'll just leave my results here:

  1. Explorer search: If you use the search functionality in a normal folder, you can save your search and call the file to start it again. There is a thread in superuser stackexchange how to do this. The mentioned .search.ms file is based on XML, so maybe someone with better knowledge on Windows path ids can modify such a file to suit your case.

  2. Parameters for control.exe: I assume you already found the control.exe executable in System32, which opens the control panel and provides various sub panels via special names, .cpl files or the /page parameter. I could not find a full command reference for control.exe, so maybe there is a parameter for an initial search term, but in my opinion its highly unlikely.

  3. Dirty hacks: I noticed, that whenever you open the control panel, the search field gets focused and so I wrote a script, which uses the clipboard to insert a search term. I used powershell, but most of this script is copy-pasted from various stackoverflow threads, so it has very low quality, but it works. Maybe you can improve this and get rid of Start-Sleep part, because the required wait time depends on the time for opening the control panel.

    [void][System.Reflection.Assembly]::LoadWithPartialName("'System.Windows.Forms")
    "date" | clip
    Start-Process control.exe
    Start-Sleep -Milliseconds 200
    [System.Windows.Forms.SendKeys]::SendWait("^{v}")
    
Community
  • 1
  • 1
Lukas Körfer
  • 13,515
  • 7
  • 46
  • 62
  • @lukegv Thanks. Explorer search: It seems to be a way to save the search result of "date" first and then reuse it inside the explorer, but I do not how to save a control panel search result, it seems that control.exe does not offer this opinion. Parameters for control.exe: This is also what I try at first, search on google for a whole afternoon with on result..... Dirty hacks: It works, maybe currently this is the only solution.. – hyzhangzhy Jan 19 '17 at 04:04