set file permissions for c:\program files\company\app\file for all users

后端 未结 2 652
不思量自难忘°
不思量自难忘° 2021-01-21 10:36

I\'ve a custom installer program that has worked fine, but it asks the user for admin permission every time it updates an application. I\'m creating a windows service that skip

2条回答
  •  一生所求
    2021-01-21 11:02

    I figured it out. I just needed to call,

    file.SetAccessControl(access);
    

    after the above. Apparently file.GetAccessControl passes back a copy of the access control and not the one that controls the file permissions for the file, until you call file.SetAccessControl with the modified permissions.

    There's another caveat I discovered with another file that the service was creating in c:\ProgramData,

    • is that the set has to occur after the file has been written. Applying the set to the file beforehand is ineffective.

提交回复
热议问题