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