我有以下 bat 文件:
@echo off
start /min powershell "& 'C:\Admin\c.ps1'"
exit
我不想显示 powershell 窗口,因为这是一个在启动时运行的管理脚本。
我的印象是使用 start/min
会解决它,但它仍然显示。
最佳答案
PowrShell 有一个隐藏的启动开关。也就是说,控制台可能会在短时间内可见,直到消失。由于这是一个管理脚本,我还建议使用 NonInteractive 开关来防止有人干扰它
@echo off
powershell -NonInteractive -File C:\Admin\c.ps1
exit
如果您根本无法让控制台可见,请考虑使用 vbs 文件启动 powershell:
Set oShell = CreateObject("WSCript.Shell")
oShell.Run("powershell -NonInteractive -File C:\Admin\c.ps1",0,False)
关于windows - 在后台运行的启动脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10823074/