Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
运行powershell脚本时,如何使.bat文件不退出?_Powershell_Batch File - Fatal编程技术网

运行powershell脚本时,如何使.bat文件不退出?

运行powershell脚本时,如何使.bat文件不退出?,powershell,batch-file,Powershell,Batch File,我将此代码放入.bat脚本以运行文件: powershell -NoProfile -ExecutionPolicy Bypass .\abc.ps1" 脚本完成后,窗口关闭,我看不到输出。如何使窗口保持打开状态?取决于您希望在窗口中留下什么。是否需要命令提示符?如果是,请使用: cmd /k powershell -NoProfile -ExecutionPolicy Bypass .\abc.ps1 你想要一个powershell窗口吗 powershell -NoExit -NoP

我将此代码放入.bat脚本以运行文件:

  powershell -NoProfile -ExecutionPolicy Bypass .\abc.ps1"

脚本完成后,窗口关闭,我看不到输出。如何使窗口保持打开状态?

取决于您希望在窗口中留下什么。是否需要命令提示符?如果是,请使用:

cmd /k powershell -NoProfile -ExecutionPolicy Bypass .\abc.ps1
你想要一个powershell窗口吗

powershell -NoExit -NoProfile -ExecutionPolicy Bypass .\abc.ps1

直接在PowerShell中运行脚本。那么您就不需要批处理文件了。为什么要在cmd中运行PS脚本呢?我想在新行中添加
pause
。我猜在批处理文件中运行它的目的是控制执行策略,而无需在机器上预先设置它。