How do I open a custom control panel programmatically, like custom.cpl? Specifically, how do I open a 64-bit cpl when running as 32-bit application?
Vista added support for canonical names so you don't have to hard code dll filenames and tab indexs
Example: WinExec("%systemroot%\system32\control.exe /name Microsoft.WindowsUpdate", SW_NORMAL);
(Names are always in english)
See MSDN for a list
XP/2000 supports "control.exe mouse" and a few other keywords, see the same MSDN page for a list (You can probably find some undocumented ones by running strings on control.exe)
just use this....
ProcessStartInfo startInfo = new ProcessStartInfo("appwiz.cpl");
startInfo.UseShellExecute = true;
Process.Start(startInfo);
UseShellExecute
part was important. Updating an old .NET project to .NET 6 required this change for me, where it wasn't previously needed. –
Originative Since I didn't find a good answer here on SO, here's the solution of my research:
- Start a new application "control" that gets the name of the control panel as its first parameter:
::ShellExecute(m_hWnd, NULL, _T("control.exe"), _T("access.cpl"), NULL, SW_SHOW);
As i previously mentioned in another Question:
If you type "Start Control" or "Control" into Command Prompt it will open Control Panel.
Therefore just run a Process.
This Code (Bellow) worked perfectly for me:
public Form1()
{
InitializeComponent();
}
#region Variables
Process p;
#endregion Variables
[...]
void myMethod()
{
try
{
p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.Start();
p.StandardInput.WriteLine("start control");
p.StandardInput.Flush();
p.StandardInput.Close();
Console.WriteLine(p.StandardOutput.ReadToEnd());
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
Step1 : Read System Directory from the machine. Step2 : Use Process to start ControlPanel
**Process.Start(System.Environment.SystemDirectory + @"\appwiz.cpl");**
© 2022 - 2024 — McMap. All rights reserved.