7

I have a file which doesn't require UAC Warning. I copied the file to another location using C#.NET

 File.Copy("Original.exe", "Copy.exe");

Now i see that Copy.exe require UAC warning to run under windows 7/Vista.

How can i compare between Original.exe and Copy.exe to see exactly what happened to the file and change it manually so that it doesn't require UAC anymore. Which tool can i use to achieve that ?

enter image description here

BOTH EXECUTABLE ARE THE SAME FILE : How to know the difference between these two files ?

Rafik Bari
  • 4,867
  • 18
  • 73
  • 123

3 Answers3

6

Windows Installer Detection Technology is the reason of such behavior. There is a set of conditions which force executable file to be considered as requiring administrator privileges:

  1. 32 bit executables
  2. Applications without a requestedExecutionLevel
  3. Interactive processes running as a Standard User with LUA enabled

Before a 32 bit process is created, the following attributes are checked to determine whether it is an installer:

  • Filename includes keywords like "install," "setup," "update," etc.
  • Keywords in the following Versioning Resource fields: Vendor, Company Name, Product Name, File Description, Original Filename, Internal Name, and Export Name.
  • Keywords in the side-by-side manifest embedded in the executable.
  • Keywords in specific StringTable entries linked in the executable.
  • Key attributes in the RC data linked in the executable.
  • Targeted sequences of bytes within the executable.

Related MSDN article: http://technet.microsoft.com/en-us/library/cc709628%28WS.10%29.aspx

Possible solutions:

  • If you are the author of executable, include manifest with specified requestedExecutionLevel
  • If you don't have access to source code - try to add or modify manifest using appropriate utilities (mt for example or maybe some generic resource editor)
  • Avoid keywords update, install and setup in executable file name
max
  • 33,369
  • 7
  • 73
  • 84
1

Afte copying the file try to set the file's acl like that:

var file = new FileInfo("copy.exe")
 var fileSecurity = file.GetAccessControl();
 fileSecurity.AddAccessRule(new FileSystemAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null),
                                                                FileSystemRights.FullControl,
                                                                AccessControlType.Allow));
 file.SetAccessControl(fileSecurity);
user844541
  • 2,868
  • 5
  • 32
  • 60
0

You may find that the problem is to do with the location rather than the file. Win 7 is very fussy, especially if you try and change anything under Program Files.

Have you tried putting the original file in the new location to check if that also required UAC approval?

DeanOC
  • 7,142
  • 6
  • 42
  • 56
  • Yes, tried that ! Whenever i use File.Copy() method the copied file require UAC approval ! – Rafik Bari Jul 15 '12 at 22:33
  • So, am I correct in assuming that if you manually rename and copy the file to the new location, then you don't need UAT approval? – DeanOC Jul 15 '12 at 22:38