Jump to content

Add a Windows Defender Exclusion


Recommended Posts

Dear Unigueers;

Although it is not advisable to deploy your Unigui application on Windows 10 (always use Server editions), here is a procedure to automatically bypass the Windows Defender firewall.

Have Fun :)


procedure TForm2.Exclusion_Windows_Defender;
var MyExeFile, Folder, St:string;
begin
  MyExeFile:='"' + 'C:\Program Files (x86)\Project1.exe'  + '"';

  try

  //1. Add Exclusion Path
    St:='/K  powershell Add-MpPreference -ExclusionPath ''' + MyExeFile + '''';
    Folder:='C:\Windows\System32';

    ShellExecute(Application.Handle,           // uses ShellAPI
     'runas',
     'cmd.exe',
     PChar(St),
     Pchar(Folder),
     SW_Hide);


  //2. Add Exclusion process
    St:='/K  powershell Add-MpPreference -ExclusionProcess ''' + MyExeFile + '''';
    Folder:='C:\Windows\System32';

    ShellExecute(Application.Handle,
     'runas',
     'cmd.exe',
     PChar(St),
     Pchar(Folder),
     SW_Hide);

  finally
  end;

  // Wait fo about 5 secondes ...
  sleep(5000);

end;

 

  • Like 3
  • Thanks 1
Link to comment
Share on other sites

  • 1 year later...
  • 2 weeks later...

Just curious, with windows defender firewall, is this a permanent rule entry or only a dynamic runtime bypass solution ?

Also would not this code be needed in the ServerModule before the binding of the port, not after at the form level as you have shown ?

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...