rha*_*vin 17 powershell powershell-2.0 powershell-remoting
我知道-noexitPowerShell 有一点开关.
无论如何都没有使用那个开关而留在shell中?
换句话说,我想要一个执行的脚本命令然后打开shell.
dea*_*dog 18
您基本上有3个选项可以阻止PowerShell控制台窗口关闭,我在博客文章中有更详细的描述.
PowerShell -NoExit "C:\SomeFolder\SomeScript.ps1"Read-Host -Prompt "Press Enter to exit"有关要修改的注册表项的详细信息,请参阅我的博客.
听起来你正在寻找选项#1或#3.
Rom*_*min 15
如果你在没有参数的情况下运行它,它将不会退出,例如通过双击它:
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'
Run Code Online (Sandbox Code Playgroud)
mjo*_*nor 10
你有没有尝试过
$host.enternestedprompt()
Run Code Online (Sandbox Code Playgroud)
这将停止执行并将它们放到嵌套提示符下.当他们退出该提示时,脚本将完成,窗口将关闭.
"do stuff"
Pause
Run Code Online (Sandbox Code Playgroud)
是的,就像命令行一样——输出:
do stuff
Press Enter to continue...:
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
95423 次 |
| 最近记录: |