Reputation: 5037
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 ?
BOTH EXECUTABLE ARE THE SAME FILE : How to know the difference between these two files ?
Upvotes: 7
Views: 2953
Reputation: 34407
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:
- 32 bit executables
- Applications without a requestedExecutionLevel
- 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:
requestedExecutionLevel
mt
for example or maybe some generic resource editor)update
, install
and setup
in executable file nameUpvotes: 6
Reputation: 2958
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);
Upvotes: 1
Reputation: 7262
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?
Upvotes: 0