start-process "chrome.exe" '--profile-directory="Default"'
当我多次运行此命令时,它将在单独的窗口中打开默认配置文件镶边。当我的默认配置文件镶边已打开时,该怎么办才能打开新标签页?
最佳答案
这将为我打开一个选项卡,而不是一个新窗口:
start-process "chrome.exe" "http://localhost:9876/debug.html",'--profile-directory="Default"'
但是,如果您只想刷新页面(如您在注释中所说),则还可以在Powershell中使用一些WindowsScript,如下所示:
# * Get a WindowsScript Shell
$WindowsScriptShell = New-Object -ComObject wscript.shell
# * Check if Chrome is running and activate it
if ($WindowsScriptShell.AppActivate('Chrome')) {
# * Take a nap to give Windows time to focus Chrome
Sleep 2
# * Refresh the page by sending the F5 Key
$WindowsScriptShell.SendKeys('{F5}')
}
# * If Chrome isn't there, tell us
Else {
Write-Output "Chrome is not started!"
}
那接近吗?
使用VBScript,您还可以在刷新之前使用
CTRL+<Number>
组合键切换到特定选项卡。所以你必须添加F5键之前的
$vbscriptShell.SendKeys('^2')
。我还尝试通过使用CTRL+T
(在VBScript中为'^ T')打开一个新标签页,但是由于某种原因,这会打开一个新窗口,然后再打开一个新标签页...
关于google-chrome - 通过Powershell启动过程在新标签页而不是新窗口中打开Chrome,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43762170/