How to run a Set-ProcessMitigation PowerShell cmdlet in Inno Setup Run section

Viewed 1286

I want to run some commands in PowerShell after my Inno Setup install.

But at the end it or shows the command without running or show the term error.

[Run]                                                                                                                                                                              
Filename: "powershell.exe"; Parameters: "-NoProfile -NoExit -Command ""& {{Set-ProcessMitigation -Name ""{app}\Game.exe"" -Disable BottomUp}"""; StatusMsg: "Configurando..."; Description: "Configurando..."; Flags: shellexec
Filename: "powershell.exe"; Parameters: "Set-ProcessMitigation -Name ""{app}\Game.exe"" -Disable HighEntropy"; StatusMsg: "Configurando..."; WorkingDir: {app}; Description: "Configurando..."; Flags: shellexec    
Filename: "powershell.exe"; Parameters: "Set-ProcessMitigation -Name ""{app}\Game.exe"" -Disable ForceRelocateImages"; StatusMsg: "Configurando..."; WorkingDir: {app}; Description: "Configurando..."; Flags: shellexec

at the first one I'm trying some but without success, the command is simple

1 Answers

There are more issues in your script. I'll address the Set-ProcessMitigation part now.

For some reason the Set-ProcessMitigation cmdlet seems to be available in 64-bit PowerShell only. As Inno Setup is a 32-bit application, it will run 32-bit PowerShell by default. So the cmdlet is not found.

To make Inno Setup run 64-bit PowerShell, add 64bit flag to the [Run] section entry. Also 64bit flag cannot be combined with shellexec flag. But I do not think you really need that, so remove the shellexec flag.

[Run]
Filename: "powershell.exe"; \
  Parameters: "-NoProfile -NoExit -Command ""Set-ProcessMitigation ..."""; Flags: 64bit
Related