Paw*_*weł 5 powershell cmd google-chrome
start-process "chrome.exe" '--profile-directory="Default"'
Run Code Online (Sandbox Code Playgroud)
当我运行此命令几次时,它会在单独的窗口中打开我的默认配置文件 chrome。当我的默认配置文件 chrome 已打开时,我该怎么做才能打开新选项卡?
这将为我打开一个选项卡而不是新窗口:
start-process "chrome.exe" "http://localhost:9876/debug.html",'--profile-directory="Default"'
Run Code Online (Sandbox Code Playgroud)
但是,如果您只想刷新页面(就像您在评论中所说的那样),您也可以在 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!"
}
Run Code Online (Sandbox Code Playgroud)
那接近吗?
使用 VBScript,您还可以CTRL+<Number>在刷新之前使用组合切换到特定选项卡。所以你必须
$vbscriptShell.SendKeys('^2')在 F5 键之前添加。我还尝试使用CTRL+T(VBScript 中的“^T”)打开一个新选项卡,但这会打开一个新窗口,然后由于某种原因打开一个新选项卡...
| 归档时间: |
|
| 查看次数: |
12903 次 |
| 最近记录: |