Search code examples
.netshellgoogle-chromeprocessprocess.start

Process.Start() with arguments to start Google Chrome


I am trying to launch Google Chrome browser from a .NET program, with arguments. But I get strange behavior.

The following launches Chrome in 'incognito' mode from a command line. It works fine.

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --incognito

But the following does not work in .NET. Chrome does open, but not incognito and it goes to this weird URL: http://xn---incognito-nu6e/

Module Module1
    Sub Main()
        System.Diagnostics.Process.Start("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "–-incognito")
    End Sub
End Module

Solution

  • You can use shortcut when call the chrome.exe instead using full path location.

    Module Module1
        Sub Main()
            System.Diagnostics.Process.Start("chrome.exe", "--incognito")
        End Sub
    End Module
    

    More: start-google-chrome-from-run-windows-key-r

    UPDATE

    I found what is your problem in your code. Your code using –-incognito in the parameter, but it should be --incognito.

    See the first character in that parameter. Should be - (hyphen-minus : U+002D) instead of (En Dash/U+2013).

    Module Module1
        Sub Main()
            System.Diagnostics.Process.Start("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "--incognito")
        End Sub
    End Module