powershell - 如何在 CMD 中退出 PowerShell.exe

标签 powershell cmd

在命令提示符中,输入 PowerShell.exe 将在 cmd 内启动 PowerShell 交互式提示符。

如何退出并返回到 cmd.exectrl+cexit()break 按钮都不起作用。

最佳答案

Ctrl-Break 有效。

exit() 可能有效,但使用括号调用函数不是 PowerShell 语法,因此它尝试使用 () 作为函数参数,但 ( ) 不是 PowerShell 中的任何内容,因此它会生成错误消息。 exit(1) 有效,因为 (1) 本身就是一个有效的表达式,其计算结果为 1,因此这与 exit 相同1,该命令在cmd环境中设置%ERRORLEVEL%返回值。

它在help about_Language_Keywords中进行了描述:

Exit

Causes Windows PowerShell to exit a script or a Windows PowerShell instance.

When you run 'powershell.exe -File ', you can only set the %ERRORLEVEL% variable to a value other than zero by using the exit statement.

关于powershell - 如何在 CMD 中退出 PowerShell.exe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42774454/

相关文章:

windows - 批量字符串连接

MySQL 错误 2002 (HY000) : Can't connect to local MySQL server through socket '/var/run/mysql.sock' in widows 7

powershell - 有人有这个 Powershell "Update-Help"命令吗?

powershell - 如何使用 PowerShell 将 HTTP 请求版本更改为 1.0

.net - 替换整行会产生重复出现的替换文本

azure - 如何在 Azure 中找到所有相关/依赖的资源?

windows - 是否可以通过 .bat/.cmd 脚本修改注册表项?

windows - CALL 通过时百分号消失

python - 我可以关闭在 Python 中使用 subprocess.Popen 打开的 CMD 窗口吗?

powershell - 从外部程序运行.ps1脚本时出现问题