0

My app has a bunch of DLLs and executables which cause RTP to cause some serious lag. In the installer, I am asking the user if he wants to allow the installer to add some exclusions in Windows Defender (if he is using it).

this is an example of what I have:

if(MessageBox.Show("can I add exclusions", "question", MessageBoxButton.YesNo,                                 MessageBoxImage.Question) == MessageBoxResult.Yes){
     var ExclusionPath = @"SOFTWARE\Microsoft\Windows Defender\Exclusions\Processes";
     using var key = Registry.LocalMachine.OpenSubKey(ExclusionPath, true);
     if(key != null){
          key.SetValue(path, 0, RegistryValueKind.DWord);
     }
}

The following exception says: Requested registry access is not allowed. I am running vs as admin and app.manifest contains

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

as an admin on powershell I can add this value and also with regedit. I would prefer not to execute powershell commands in my installer. Is there a way to do this?

I've made sure I'm using the right registry key and that my program is running with admin rights. I'm not sure what else I can do. I'd also prefer not to use ProcessStart to run a ps cmdlet

JackieSL9
  • 1
  • 1
  • Are you actually admin when running the app? Check https://stackoverflow.com/a/5953294/14868997 – Charlieface May 02 '23 at 10:58
  • @Charlieface Yes I am. Besides just trusting my app.manifest, I am also checking whether I'm running as admin during runtime. – JackieSL9 May 04 '23 at 14:59

0 Answers0