使用 -NoExit 启动 PowerShell 不起作用

2024-02-25

需要在 PowerShell 中启动多个作业,但它们应该位于不同的会话中。因此,要启动一个,可以使用:

Start-Process powershell -ArgumentList "-command &{Get-Process}","-noexit","-noprofile"

但命令一完成,新窗口就会关闭。即使我正在使用-NoExit范围。根据本文 https://msdn.microsoft.com/en-us/powershell/scripting/core-powershell/console/powershell.exe-command-line-help and 这个问题 https://stackoverflow.com/questions/36112419/how-to-start-powershell-in-a-new-window-from-bat-and-run-a-ps1-without-exiting,这应该有效。甚至尝试通过等待用户输入来阻止窗口,但它只是关闭。


虽然命令参数已命名,但位置仍然很关键(请参阅 PowerShell.exe /?):

Start-Process powershell -ArgumentList "-noexit", "-noprofile", "-command &{Get-Process}"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 -NoExit 启动 PowerShell 不起作用 的相关文章

随机推荐