我尝试了以下方法:
$edge = New-Object -com microsoft-edge.application
$edge.visible = $true
$edge.FullScreen = $true
但是我得到错误:
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
我在这里做错了什么吗?
编辑 17/07/2019 - 我已更改为以下内容:
$edge = Start-Process -FilePath ($Env:WinDir + "\explorer.exe")
-ArgumentList
"shell:Appsfolder\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge"
$edge.visible = $true
$edge.FullScreen = $true
现在 Edge 打开了,但是 Visible 和 Fullscreen 命令返回了错误 - 有人有什么想法吗?
干杯
最佳答案
我认为这可能是解决方案:
start microsoft-edge:http://google.com
$wshell = New-Object -ComObject wscript.shell;
$wshell.AppActivate('Google - Microsoft Edge')
Sleep 2
$wshell.SendKeys('{F11}')
我在这里找到了上面的代码:start microsoft edge in fullscreen
您可以根据需要发送不同的键: How to send CTRL or ALT + any other key?
您可以找到要对 Edge 窗口执行的任何操作的快捷键。
你可以试试这个(来源是下面的链接):
Start-Process -FilePath ($Env:WinDir + "\explorer.exe") -ArgumentList "shell:Appsfolder\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge"
还有一种在隐身模式下打开它的方法:
关于windows - 如何使用 Powershell 变量打开 Edge?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57053312/