Ok, i am using this code to get all the installed programs on the users machine.
string uninstallKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(uninstallKey))
{
foreach (string skName in rk.GetSubKeyNames())
{
using (RegistryKey sk = rk.OpenSubKey(skName))
{
try
{
listBox1.Items.Add(sk.GetValue("DisplayName"));
}
catch
{
MessageBox.Show("Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
All of the programs are listed in a listbox. How do i get the “programName”.exe of that program. Like calculator is calc.exe ( i want the calc, but not the .exe ) How do i do that?
I am doing this so i can say:
System.Diagnostics.Process.Start(exeName);
you can use TrimEnd
EDIT:
To start a program from
System.Diagnostic.Process.Start, you don’t need to trim off “.exe”, you can leave it as it and it will exectue