英文:
Is it possible in one PowerShell line to start Microsoft Edge with multiple tabs?
问题
我想通过单个PowerShell命令在快捷方式中启动Microsoft Edge(Chromium)并打开多个选项卡。以下是适用于一个选项卡的有效命令:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command "& start microsoft-edge:https://www.outlook.com"
但我不清楚如何添加一组网站。类似于:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command "& start microsoft-edge:https://www.outlook.com;https://www.google.com"
这个命令不起作用,但我正在寻找类似这样的解决方案。请注意,我没有对我正在尝试执行此操作的工作站具有管理员访问权限。
英文:
I'd like to be able to start Microsoft Edge (Chromium) with multiple tabs via a single PowerShell command in a shortcut (not a script). Here is what I have that works for one tab:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command "& start microsoft-edge:https://www.outlook.com"
but I am unclear how to add on a set of sites. Something like:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command "& start microsoft-edge:https://www.outlook.com;https://www.google.com"
That doesn't work, but I'm looking for something along those lines. Note, I do not have admin access to the workstation where I'm trying to do this.
答案1
得分: 3
以下是您要翻译的内容:
"据我所知,只有在通过microsoft-edge:
协议方案启动时才支持单个URL。
但是,您可以通过位于目录$env:LOCALAPPDATA\Microsoft\WindowsApps
中的MicrosoftEdge.exe
可执行文件来启动Edge,该可执行文件接受多个URL(在这种情况下请注意使用,
分隔它们):
上述命令等同于(请注意使用了-Command
CLI参数以及 Start-Process
的完整名称和参数名称):
实际上,在这种情况下,对于基于可执行文件的调用,甚至不需要Start-Process
,因为使用直接调用时,GUI可执行文件会以异步方式启动:
请注意,需要使用&
,因为可执行文件路径包含变量引用,并且现在两个URL以_空格_分隔(作为单独的参数传递)。
相反,如果您希望在返回调用之前等待Edge关闭,通常会使用Start-Process -Wait
,但是很遗憾,在PowerShell 7.3.3之前,对于AppX应用程序(如Microsoft Edge),这种方法通常不起作用 - 请参阅GitHub问题#10996。"
英文:
<!-- language-all: sh -->
As far as I'm aware, only a single URL is supported when you launch via the microsoft-edge:
protocol scheme.
However, you can launch Edge via the MicrosoftEdge.exe
executable located in directory $env:LOCALAPPDATA\Microsoft\WindowsApps
, which does accept multiple URLs (note the need to separate them with ,
in this case):
powershell.exe "start $env:LOCALAPPDATA\Microsoft\WindowsApps\MicrosoftEdge.exe https://example.org, https://google.com"
The above is short for (note the use of the -Command
CLI parameter and the use of Start-Process
's full name and parameter names):
powershell.exe -Command "Start-Process -FilePath $env:LOCALAPPDATA\Microsoft\WindowsApps\MicrosoftEdge.exe -ArgumentList https://example.org, https://google.com"
In fact, with an executable-based invocation you don't even need Start-Process
in this case, given that a GUI executable launches asynchronously even with direct invocation:
powershell.exe "& $env:LOCALAPPDATA\Microsoft\WindowsApps\MicrosoftEdge.exe https://example.org https://google.com"
Note the need to use &
, because the executable path contains a variable reference, and that the two URLs are now space-separated (passed as individual arguments).
Conversely, if you wanted to wait for Edge to close again before returning from the call, you would normally use Start-Process -Wait
, but this is not effective with AppX applications such as Microsoft Edge, unfortunately, at least as of PowerShell 7.3.3 - see GitHub issue #10996.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论