打开新的 powershell 控制台并运行命令

mic*_*urt 4 powershell command-line

我想在我的脚本中添加一行,打开一个新的 Power Shell 控制台并在新窗口中运行 ping 命令。

tmf*_*all 5

start-process powershell.exe -argument '-nologo -noprofile -executionpolicy bypass -command Test-Connection ipAddressToPing; read-host "press enter"'
Run Code Online (Sandbox Code Playgroud)

您可以将 IP 地址添加到脚本中或将其省略,它会在运行时询问您。如果您希望窗口立即关闭,您可以删除读取主机“按回车”。