"This file came from another computer and might be blocked to protect this computer." - How to programmatically remove this attribute in C# .net?

user3418061 picture user3418061 · Mar 14, 2014 · Viewed 21.1k times · Source

I made a program in C#. It copies itself to startup if the user ticks the box to do so.

The application adds itself to startup using the registry key "SOFTWARE\Microsoft\Windows\CurrentVersion\Run".

It works fine, aside from the problem that every time the machine is restarted, the user is prompted whether they're sure they want to run the program because it's blocked by Windows because it "comes from another computer".

Any way I can get rid of this Windows "blocked" flag through the code so that the user isn't prompted everytime the program tries to run itself?

Thanks

Answer

Brendan Grant picture Brendan Grant · Mar 14, 2014

When downloaded/copied to the machine, Windows attached a Zone Identifier (http://msdn.microsoft.com/en-us/library/dn392609.aspx) based in the location it the file came from (http://msdn.microsoft.com/en-us/library/ms537183.aspx)

In order to unblock the file, you will either have to have the user open up the file properties and click the Unblock button, or remove it yourself.

You can find more information on how this happens and a few ways to do so (including with code) here: http://weblogs.asp.net/dixin/archive/2009/03/14/understanding-the-internet-file-blocking-and-unblocking.aspx