Process.Start() with arguments to start Google Chrome

我的梦境 提交于 2019-12-08 06:51:36

问题


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

回答1:


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 - instead .

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


来源:https://stackoverflow.com/questions/17396147/process-start-with-arguments-to-start-google-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!