Open Default Apps (or Any Other Settings) in Windows 10

Sometimes you need to open windows settings programmatically. In my case mostly due to security restrictions - you can’t just go around the OS and change the settings, you need to ask the user to do that.

Luckily Windows 10 makes it easy by supporting the ms-settings: URI scheme, and there are plethora of system dialogs you can open with it.

In my case, I needed to open “default apps” window (ms-settings:defaultapps) and this is how i did it:

Header:

1void open_mssettings(const std::wstring name);
2
3void open_default_apps();

Implementation:

 1void open_mssettings(const std::wstring name)
 2{
 3    wstring url(L"ms-settings:");
 4    url += name;
 5
 6    HINSTANCE hi = ::ShellExecute(
 7        nullptr,
 8        L"open",
 9        url.c_str(),
10        nullptr,
11        nullptr,
12        SW_SHOWDEFAULT);
13}
14
15void open_default_apps()
16{
17    open_mssettings(L"defaultapps");
18}

Effect:

Have feedback or questions? Feel free to email me.