setting UAC settings of a file in C#
Posted
by Inam Jameel
on Stack Overflow
See other posts from Stack Overflow
or by Inam Jameel
Published on 2010-04-29T12:23:21Z
Indexed on
2010/04/29
12:27 UTC
Read the original article
Hit count: 365
Hi guys.
i want to give a file(already present on the client computer .exe) permissions to always execute with administrative permissions.
please note that the file i wants to give permissions is already on target machine. and i want to change permissions of that file through another program written in c# and it has administrative permissions to do everything.
kindly let me know how to do it i am using this code
System.Security.AccessControl.FileSecurity fs = File.GetAccessControl(@"c:\inam.exe");
FileSystemAccessRule fsar = new FileSystemAccessRule("Everyone", FileSystemRights.FullControl, AccessControlType.Allow);
fs.AddAccessRule(fsar);
File.SetAccessControl(@"c:\inam.exe", fs);
this code will change the permissions correctly but still when i execute inam.exe after executing this code the UAC not appeared and also the inam.exe cant perform administrative operations.
actually i have already deployed an application on more than 10,000 clients so wants to release a patch to resolve the administrative rights issue.
© Stack Overflow or respective owner