There is a script that adds a port to the Windows Firewall and an installer for InnoSetup that runs this script as an administrator.

script.vbs:

Dim objShell Set objShell = WScript.CreateObject("Wscript.Shell") objShell.run "netsh advfirewall firewall add rule name=Test protocol=TCP localport=5433 action=allow dir=IN" 

Run in InnoSetup:

 [Run] Filename: "{tmp}\script.vbs"; Flags: shellexec runascurrentuser; 

How can I run a script without a console pop-up window ?

  • This is all in the documentation. Add the runhidden flag. - Yaant
  • @Yaant, The console window still appears for a moment. - user214690
  • Hm And if you do without the intermediate .vbs file and, accordingly, the shellexec flag, and run netsh directly with the necessary parameters? - Yaant
  • one
    Then you can try instead of using the shellexec flag shellexec call wscript.exe directly with parameters. Or better, cscript.exe , because there is a suspicion that the window opens itself wscript.exe - Yaant
  • one
    Well, runhidden is still needed. And still it is worth trying exec instead of run . By the way, it may turn out that it will be enough to use exec in the original version to solve the problem. - Yaant

1 answer 1

This decision helped:

 [Files] Source: "C:\script.vbs"; DestDir: {tmp}; Flags: ignoreversion; AfterInstall: ExecScript; [Code] procedure ExecScript; var ResultCode: Integer; begin if not Exec(ExpandConstant('cscript.exe'), 'script.vbs', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then begin MsgBox('Failed to execute script.vbs file' + #13#10 + SysErrorMessage(ResultCode), mbError, MB_OK); end; end; 

No more console popups. Thank you @Yaant for valuable comments.