我想:
1.在Windows中,确定系统的默认浏览器
2.将浏览器传递给新对象定义
3.打开浏览器并转到URL
到目前为止,这是可行的:
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
但是,我知道如何打开浏览器并转到url的唯一方法是:
$IE = new-object internetexplorer.application
$IE.navigate2("www.microsoft.com")
$IE.visible=$true
这不起作用:
$browser_object = new-object -com $browserPath.application
这也不是:
$browser_object = new-object -com firefox.application
任何帮助将非常感激。
克里斯
最佳答案
Start-Process cmdlet将打开您的默认浏览器并导航到URL:
Start-Process $url
关于url - 如何基于Power Shell中的Function输出创建对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7689923/