Accessing Windows Settings Dialogs from Code via Shell Commands
Rick Strahl discusses how developers can open Windows Settings dialogs directly from code or shell commands using the ms-settings:
protocol handler. The article provides practical usage examples for applications built with .NET and Windows technologies.
Accessing Windows Settings Dialogs from Code via Shell Commands
Author: Rick Strahl
Posted: March 13, 2025 • from Maui, Hawaii
Overview
Windows provides a built-in protocol handler—ms-settings:
—which allows developers and users to open specific Windows Settings dialogs directly, bypassing the usual navigation. This can be invoked via shell commands, from within applications, or even from the browser, streamlining user experience when your app needs users to adjust specific system settings.
Key Use Cases
- Prompting users to change system settings required for app features (e.g., microphone access for speech recognition)
- Rapid navigation to configuration pages from apps or scripts
- Automating diagnostics or support workflows
Example Command Usage
Shell Commands in Applications:
- Using
.NET
methods:ShellExecute()
,Process.Start()
- Terminal commands:
start
(DOS),start-process
(PowerShell) - Directly in browsers
Screenshot: Windows Settings Through Shell Commands
You can directly access specific Windows Settings dialogs using
ms-settings:
URIs in your applications or scripts.
Real-World Application Example
In the Markdown Monster app, if speech recognition fails due to missing permissions, the app can open the exact relevant Settings dialog:
try
{
await EnsureCompiledAsync();
_ = _recognizer.ContinuousRecognitionSession.StartAsync();
_isDictating = true;
}
catch (Exception ex) when (ex.Message.Contains("privacy"))
{
// Open the settings page for speech recognition
Westwind.Utilities.ShellUtils.ShellExecute("ms-settings:privacy-speech");
}
How to Activate ms-settings Handlers
Terminal Activation
PowerShell/DOS:
# DOS/Command Prompt
start "ms-settings:privacy-speech"
# PowerShell
start-process "ms-settings:privacy-speech"
WSL Terminal:
explorer.exe ms-settings:privacy-speech
Code Activation (.NET/C#)
Using code with .NET
platforms, you can launch these dialogs via:
Process.Start("ms-settings:privacy-speech");
// or your own helper
ShellUtils.ShellExecute("ms-settings:privacy-speech");
ShellUtils.GoUrl("ms-settings:privacy-speech");
All leverage the Windows ShellExecute
API, which runs these commands.
Reference for ms-settings Commands
You can jump to many Windows configuration pages; see the full reference:
Other protocol handlers exist that let you trigger different built-in Windows features from code or URLs (see MS docs for exploration).
What Are Protocol Handlers/URI Schemes?
- Protocol Handler: Globally registered command invoked via a URL prefix (e.g.,
ms-settings:
). - Allows apps or browsers to trigger built-in operating system dialogs or app-specific features.
- Used for system features (like settings) or custom integrations (Markdown Monster, Teams, Zoom, etc.).
- Example: open a Markdown document in Markdown Monster from the browser via its own handler.
Why This Is Useful
While not something you might use daily, directly opening configuration dialogs improves user guidance and troubleshooting, especially around complex features like security and permissions where normal navigation is cumbersome.
Resources
Related Reading
- Adding minimal OWIN Identity Authentication to an Existing ASP.NET MVC Application
- Keeping Content Out of the Publish Folder for WebDeploy
- Using SQL Server on Windows ARM
- Map Physical Paths with an HttpContext.MapPath() Extension Method in ASP.NET
Original post by Rick Strahl. If you found this content helpful, consider making a small donation.
This post appeared first on “Rick Strahl’s Blog”. Read the entire article here