I wanted to: 1. In Windows, Determine the system's default browser 2. Pass the browser to a new-object definition 3. Open the browser and goto a url
This is what works so far:
Function GET-DefaultBrowserPath {
#Get the default Browser path
New-PSDrive -Name HKCR -PSProvider registry -Root Hkey_Classes_Root | Out-Null
$browserPath = ((Get-ItemProperty 'HKCR:\http\shel\open\command').'(default)').Split('"')[1]
return $browserPath
}
GET-DefaultBrowserPath
However, the only way I know how to open a browser and go to a url is:
$IE = new-object internetexplorer.application
$IE.navigate2("www.microsoft.com")
$IE.visible=$true
and this does not wo开发者_Go百科rk:
$browser_object = new-object -com $browserPath.application
nor does this:
$browser_object = new-object -com firefox.application
Any help would be much appreciated.
Chris
The Start-Process cmdlet will open your default browser and navigate to the URL:
Start-Process $url
Try this:
$path = GET-DefaultBrowserPath
$url = "www.microsoft.com"
&$path $url
精彩评论