Thursday, August 11, 2011

Installing executable from remote location by suppressing the Open File Prompt

Many times while running a script/application exe from a network we get an error that the application is not from a trusted source and if we want to install the particular application or not.
This error comes because the source is not digitally signed and the Operating System prompts to ask from user if it is a known source to user or if something malicious is being run from network. This is just to protect the end users from the malicious software or Virus attack.


This behavior was introduced in Windows XP SP2 because of the addition of the Attachment Execution Services (AES). Every program that is run by using the ShellExecute() API passes through AES. AES considers the downloaded update file to be from the Internet Zone. Therefore, AESdisplays the Open File - Security Warning dialog box. AES examines the file to see whether the file has a file stream of the type Zone.Identifier. Then AES determines what zone the file is from and what level of protection to apply when the file is run.

You can use the below code to suppress this message for your application to work fine.

set oShell= CreateObject("Wscript.Shell")

set oEnv = oShell.Environment("PROCESS")


<Your Code here>


Please note that you should not set this as a permanent environment variable as it will disable all Zone Checking and it is not recommended.

No comments: