I am having problems with running an installation file that I grab off of a local server. Whenever I attempt to run it I get a "Open File - Security Warning" window which ask me again if I want to Run the program. I know of a couple ways around this problem but I am searching for another...
1) Run the program and make sure to uncheck the "Always ask before opening this file" option.
2) Go to the files Properties window and click the 'Unblock' button.
However, I wish to unblock this through C# code. This is becuase the program I am writing will call these types of installers and I don't wish to force my users to 'Unblock' the files themselves.
I attempted to do it with SendKeys:
private void GrantAccess()
{
// Get a handle to the security window.
Thread.CurrentThread.Join(1000); IntPtr SecurityHandle = FindWindow("#32770", "Open File - Security Warning"); // Verify that installer is a blocked file. if (SecurityHandle != IntPtr.Zero){
SetForegroundWindow(SecurityHandle);
SendKeys.SendWait("%w"); Thread.CurrentThread.Join(500); SendKeys.SendWait("%w"); Thread.CurrentThread.Join(500); SendKeys.SendWait("%r"); Thread.CurrentThread.Join(500);}
}
but ran into some problems with running this funciton in another Thread multiple times throughout my code. Therefore, I want to avoid the SendKeys method if possible.
So I guess I am asking if there is a simple way to unblock a file. Is there a registry key or something that needs to be changed Any help is appreciated.
Thanks