Open a URL in Firefox via PowerShell?

2019-06-23 14:41发布

问题:

I want the url to be opened in Firefox by Powershell script

To make things a bit difficult, Firefox is not the default browser and it is a portable Firefox version.

Edit:

There seems to be some problem with my portable firefox installation. Even when making it the default browser, it doesn't work properly when invoked by start url.

I rechecked it with a fresh install of portable Firefox 4.0 from here and ittlefoot's solution works fine.

回答1:

Using the website as the first argument should work.

X:\path-to-firefox\firefox.exe "http://website-to-launch.com/yadda"


回答2:

try

[system.Diagnostics.Process]::Start("firefox","your-url")

not sure it'll work on portable version you might have to (replace "firefox" with the path to the portable exe) however, it works even if firefox is not default.