2

I want my user to be able to press a button and start a given control panel item, such as the Set Associations window. Must work for any Windows version, but the path would lead here:

Control Panel\All Control Panel Items\Default Programs\Set Associations

I am using C#/WPF to do this, but can't find information on how to do this for a specific Control Panel page like above and that works for all Windows versions.

Thanks!

UPDATE

The following works to access a page:

System.Diagnostics.Process.Start("C:\\Windows\\System32\\control.exe", "/name Microsoft.DefaultPrograms /page pageFileAssoc");

1 Answers1

2

You should use Process class to run a canonical address of the control panel item you want to show. You can show control panel window by executing c:\windows\system32\control.exe then you should add the canonical name as parameters for this process.

public static void Main()
    {
        Process myProcess = new Process();

        try
        {
            myProcess.StartInfo.FileName = "c:\\windows\\system32\\control.exe";
            myProcess.Start();
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }
    }

see here for more info on canonical names.

Cameron MacFarland
  • 70,676
  • 20
  • 104
  • 133
Emad
  • 3,809
  • 3
  • 32
  • 44
  • How do you pass the canonical name and access a specific page? –  Oct 04 '15 at 17:04
  • This: `System.Diagnostics.Process.Start("C:\\Windows\\System32\\control.exe", "/name Microsoft.DefaultPrograms");` seems to work, but I can't figure out how to access any of the sub pages. I want to access `pageFileAssoc`. –  Oct 04 '15 at 17:13
  • 1
    Nevermind. I found that `/name Microsoft.DefaultPrograms /page pageFileAssoc` works. Cheers! –  Oct 04 '15 at 17:18