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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...