Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

.net

windows

exe

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

like image 427
user3418061 Avatar asked Mar 14 '14 01:03

user3418061


People also ask

How do I unblock a security file?

1 – Right click on the file that is blocked. 2 – Select Properties from the options that appear. 3 – Click on the General tab in the Properties window. 4 – Click on the Unblock option next to the Security detail which says “This file came from another computer and might be blocked to help protect this computer.”


1 Answers

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

like image 87
Brendan Grant Avatar answered Sep 19 '22 09:09

Brendan Grant