阻止 Powershell 退出 [英] Stop Powershell from exiting
本文介绍了阻止 Powershell 退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道 PowerShell 有一个很小的 -noexit
开关.
I know that there is that little -noexit
switch for PowerShell.
有没有办法在不使用那个开关的情况下留在 shell 中?
Is there anyway of staying in the shell without using that switch?
换句话说,我想要一个脚本命令,它会执行然后让 shell 保持打开状态.
In other words, I want a script command(s) that executes then leaves the shell open.
推荐答案
如果你不带参数运行这个脚本,它不会退出,例如双击它:
This script will not exit if you run it without arguments, e.g. by double-clicking on it:
param($Work)
# restart PowerShell with -noexit, the same script, and 1
if (!$Work) {
powershell -noexit -file $MyInvocation.MyCommand.Path 1
return
}
# now the script does something
# this script just outputs this:
'I am not exiting'
这篇关于阻止 Powershell 退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文