如何使用Powershell变量打开Edge? [英] How to open Edge using Powershell variable?

查看:770
本文介绍了如何使用Powershell变量打开Edge?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了以下操作:

$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

我在这里明显做错了吗?

Am I doing something obviously wrong here?

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

Edit 17/07/2019 - I have changed to below:

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

所以现在Edge会打开,但是可见"和全屏"命令会返回错误-任何人有任何想法吗?

So now Edge opens but the Visible and Fullscreen commands return errors - anyone have any ideas?

欢呼

推荐答案

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

I think this might be the solution:

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

我在这里找到了上面的代码:在全屏模式下启动Microsoft Edge

I found the above code here:start microsoft edge in fullscreen

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

You can send edge different keys depending on what you want: How to send CTRL or ALT + any other key?

您可以在Edge窗口中找到要执行的操作的快捷键.

You could find the key shortcut to whatever you want to do to the Edge window.

您可以尝试使用此方法(来源是下面的链接):

You could try this(source is link below):

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

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

There is also a way to open it in Incognito Mode:

如何通过以下方式在私有模式下启动Microsoft Edge: PowerShell

这篇关于如何使用Powershell变量打开Edge?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆