如何使用 Powershell 变量打开 Edge?

Naz*_*Naz 4 windows powershell microsoft-edge

我尝试了以下方法:

$edge = New-Object -com microsoft-edge.application
$edge.visible = $true
$edge.FullScreen = $true
Run Code Online (Sandbox Code Playgroud)

但我得到错误:

New-Object : Retrieving the COM class factory for component with CLSID 
{00000000-0000-0000-0000-000000000000} failed
due to the following error: 80040154 Class not registered (Exception from 
HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
At line:1 char:9
+ $edge = New-Object -com microsoft-edge.application
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ResourceUnavailable: (:) [New-Object], COMException
+ FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand
Run Code Online (Sandbox Code Playgroud)

我在这里做错了什么吗?

编辑 17/07/2019 - 我已更改为以下内容:

$edge = Start-Process -FilePath ($Env:WinDir + "\explorer.exe") 
-ArgumentList 
"shell:Appsfolder\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge"
$edge.visible = $true
$edge.FullScreen = $true
Run Code Online (Sandbox Code Playgroud)

所以现在 Edge 打开但 Visible 和 Fullscreen 命令返回错误 - 任何人有任何想法吗?

干杯

Zhi*_* Lv 6

您可以使用以下命令打开 Microsoft Edge 浏览器并导航到特殊 URL。

start microsoft-edge:http://google.com
Run Code Online (Sandbox Code Playgroud)

编辑:

如果您想使用Edge Webdriver打开IE浏览器,可以从此链接下载Edge webdriver ,并参考本文使用。


tec*_*029 5

我认为这可能是解决方案:

start microsoft-edge:http://google.com
$wshell = New-Object -ComObject wscript.shell;
$wshell.AppActivate('Google - Microsoft Edge')
Sleep 2
$wshell.SendKeys('{F11}')
Run Code Online (Sandbox Code Playgroud)

我在这里找到了上面的代码:全屏启动microsoft edge

您可以根据需要发送不同的键: 如何发送 CTRL 或 ALT + 任何其他键?

您可以找到对 Edge 窗口执行任何操作的快捷键。

你可以试试这个(来源是下面的链接):

Start-Process -FilePath ($Env:WinDir + "\explorer.exe") -ArgumentList "shell:Appsfolder\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge"
Run Code Online (Sandbox Code Playgroud)

还有一种方法可以在隐身模式下打开它:

如何通过 PowerShell 以私有模式启动 Microsoft Edge