I currently have the following code that is launched via a button within a data grid on a WPF application:
private static string GetStandardBrowserPath()
{
string browserPath = string.Empty;
RegistryKey browserKey = null;
try
{
//Read default browser path from Win XP registry key
browserKey = Registry.ClassesRoot.OpenSubKey(@"HTTP\shell\open\command", false);
//If browser path wasn't found, try Win Vista (and newer) registry key
if (browserKey == null)
{
browserKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http", false); ;
}
//If browser path was found, clean it
if (browserKey != null)
{
//Remove quotation marks
browserPath = (browserKey.GetValue(null) as string).ToLower().Replace("\"", "");
//Cut off optional parameters
if (!browserPath.EndsWith("exe"))
{
browserPath = browserPath.Substring(0, browserPath.LastIndexOf(".exe") + 4);
}
//Close registry key
browserKey.Close();
}
}
catch
{
//Return empty string, if no path was found
return string.Empty;
}
//Return default browsers path
return browserPath;
}
This returns the browser path as follows:
"c:\\program files\\mozilla firefox\\firefox.exe -osint -url %1"
What I want to do is add another command line onto the end of the .exe to force the browser to open in private mode and the end user knows this will happen, but I am unsure how to do this. The browsers I want to do this with are:
- Google Chrome
- Fire Fox
- Opera
- Internet Explore
e.g.
"c:\\program files\\mozilla firefox\\firefox.exe -private -osint -url %1"
or
"c:\\program files (x86)\\google\\chrome\\application\\chrome.exe -incognito -- %1"