Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i now wrote a driver,but i encounter a really troublesome problem , when i installed the driver on other computer is always failed ,and i debug the program found out that the install software didn't have the right to write or do any changes in the drivers folder ,is there anyone who now how to change the user's right.please help.
Posted

1 solution

Take a look at the following article, Delete Undeletable Folders under Vista or Windows 7[^]. It explains how to gain access to the files / folder which are otherwize not accessable as in your case.

From the article
=========================
The main idea behind the program is to fix the access rights for every file and folder.

private static void FixAccess(FileSystemSecurity sec)
{
    string currentUser = WindowsIdentity.GetCurrent().Name;
    sec.AddAccessRule(new FileSystemAccessRule
    (currentUser, FileSystemRights.FullControl, AccessControlType.Allow));
}

I also clear all the existing rules in the hope that it will avoid conflicts.

foreach (FileSystemAccessRule fsar in sec.GetAccessRules
    (true, true, typeof(System.Security.Principal.NTAccount)).OfType<filesystemaccessrule />().ToArray())
{
    sec.RemoveAccessRuleAll(fsar);
}

Unfortunately, most of this was failing at the beginning and I could not find out why. I thought the solution was to fix the ownership of the file.

private static void FixOwner(FileSystemSecurity sec)
{
    var sid = sec.GetOwner(typeof(SecurityIdentifier));
    string currentUser = WindowsIdentity.GetCurrent().Name;
    var ntAccount = new NTAccount(currentUser);
    sec.SetOwner(ntAccount);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900