VollRahm
VollRahm

Reputation: 437

Why is Windows Defender blocking my C# Application when it sets an Autostart?

I'm using the following code to set an Autostart of my Application:

using (RegistryKey rk = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
{
           rk.SetValue("Application", Application.ExecutablePath); //add autostart
}

When i compile it my Windows Defender instantly deletes the File because it found "Trojan:Win32/Bearfoos.A!ml" and "Trojan:Win32/Azden.A!cl"

I've have already tried to remove those lines without success. This is one of the easy ways to create an autostart application, so i would want to do it.

Upvotes: 3

Views: 3093

Answers (1)

VollRahm
VollRahm

Reputation: 437

I got it. Apparently you can't have this in the Form constructor, you need to edit the Registry AFTER the Form_Shown() Method otherwise Windows Defender get's you. I can't undertsand the logic behind this :thinking:

Upvotes: 1

Related Questions