更新时间:2022-12-02 21:06:23
使用 start
命令.在 CMD 提示中,尝试:
Use the start
command. In a CMD prompt, try:
启动 powershell -noexit -command "get-date"
对于开始/运行(或 Win+r)提示,请尝试:
For Start/Run (or Win+r) prompt, try:
cmd/c start powershell -noexit -command "get-date"
-noexit
会告诉 Powershell,嗯,不要退出.如果省略此参数,将执行该命令,您可能只会看到 Powershell 窗口的一瞥.对于交互式使用,这是必须的.对于脚本,不需要.
The -noexit
will tell Powershell to, well, not to exit. If you omit this parameter, the command will be executed and you are likely to just see a glimpse of a Powershell window. For interactive use, this is a must. For scripts it is not needed.
start
是 CMD 的内部命令.在 Powershell 中,它是 Start-Process
的别名.这些不是一回事.
start
is an internal command for CMD. In Powershell it is an alias for Start-Process
. These are not the same thing.
至于为什么窗口是黑色的,那是因为Powershell.exe的快捷方式设置为背景蓝色.
As for why the window is black, that's because the shortcut for Powershell.exe is configured to set the background blue.