通过 NSIS 静默运行 Powershell

Ims*_*msa 4 powershell nsis silent-installer

我有一个 powershell 脚本,我想以静默方式运行。我正在使用 NSIS 脚本,当 .exe 文件运行时它仍然会提升 powershell 命令提示符。

有没有办法让它默默地。

!include FileFunc.nsh
!include x64.nsh


OutFile "script.exe"
SilentInstall silent
RequestExecutionLevel admin

Function .onInit
    SetSilent silent
FunctionEnd

Section
    SetOutPath $EXEDIR
    File "script.ps1"
    IfSilent 0 +2
        ExecWait "powershell -ExecutionPolicy Bypass .\script.ps1 -FFFeatureOff"
SectionEnd

Function .onInstSuccess
    Delete "script.ps1"
FunctionEnd
Run Code Online (Sandbox Code Playgroud)

这里有一个使用静默安装的示例,但是当我尝试它时无法使其工作。http://nsis.sourceforge.net/Examples/silent.nsi

bea*_*ker 5

尝试这个:

ExecWait "powershell -ExecutionPolicy Bypass -WindowStyle Hidden -File .\script.ps1 -FFFeatureOff"
Run Code Online (Sandbox Code Playgroud)

详细信息:PowerShell.exe 命令行帮助