Run powershell script or whitelist installation directory before installing in inno setup

164 views Asked by At

I'm using inno setup where user can choose the directory to install the software.exe.

But currently halfway through the installation, Windows Defender would delete/quarantine the exe file as it think it's a virus. My current fix was to create a folder, whitelist the folder in defender then run setup and install to that folder manually.

Is there a way to automate this process in Inno Setup, where after user chose the install directory, it would whitelist that folder before installing?

I saw a few people running Powershell script, but how do I run this script after Inno setup create the folder, and before installing the .exe?

1

There are 1 answers

2
Martin Prikryl On

Assuming that you create the directory using Dirs section entry, use AfterInstall parameter to tun your custom code to execute a PowerShell:

[Dirs]
Name: "{app}\data"; AfterInstall: AfterDirectoryCreated
[Code]

procedure AfterDirectoryCreated;
var
  ResultCode: Integer;
begin
  if Exec('powershell', Params, '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then
  begin
    Log('PowerShell executed successfully');
  end
    else
  begin
    Log('PowerShell failed to execute');
  end;
end;

Though changing users antivirus settings is imo an unacceptable security breach. Fix your application not to be detected as virus instead.