PowerShell Script after install

inno-setup

Solution

[Run]
.....; Description: Run Script; Flags: postinstall

(See the help for more details.) By default this will display a checkbox and run under the original user's context (although it depends a bit on how the installer is run).

You might want to reconsider this approach, though; if you are performing a machine-wide install then you should probably open the port machine-wide too. You can do this with pure Inno code calling WinAPIs -- no powershell required. (Which is a good thing, because it might not be installed.)

Alternatively if you want to keep it a per-user setting you should consider making your application prompt the user for a decision on first run. After all, why give an option to only one of the many possible users of your app?

Problem

Newbie question: I would like to run a powershell script (.ps1) at the end of the inno-setup install. Can anyone give me a tip on where to put this? I want the user prompted to be asked if he wants to run this script. Oh yes, what this script does is run netsh.exe to open up a port, the script is clever and it grabs Env:username and Env:userdomain from the current context. Would the context be the admin who is running the setup? or would it be the original user that ran the setup.exe?

Original source