0

I have Word Add-in, which keeps updating "winword.exe.config.xml" file present at "C:\program files\microsoft office\.

I need to write changes to this file,update few parameters while running MS word.

when the User is "Administrator", the changes are updated successfully in the file without any problem.

In case of Non - Admin accounts(they do not have the file permission), the changes are not reflected as the write permission is not there.

Is there any way i can write to these files successfully from C# code for Non-Admin accounts also, without asking user to change the permission of the file.

Pawan Kumar
  • 247
  • 6
  • 21
  • Isn't the idea of non-admin accounts to don't allow modifications of protected files without asking for permission? – Volkmar Rigo May 22 '12 at 09:08

1 Answers1

0

If you are in control of the add-in then you simply need to choose a different location for the config file. A location to which a standard user has write permissions.

If you are not in control of the add-in, then you have two viable options:

  1. Always run Word as administrator.
  2. Add an ACL to the config file to grant write access to standard users.

You ask:

Is there any way I can write to these files successfully from C# code for non-admin accounts also, without asking user to change the permission of the file.

No there is not. Just imagine if there was a way to do this. That would completely negate the utility of file system security.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • I tried the option of writing the config file to some other location where user have the permission but when MS Word loads , it always loads with the configuration file from default directory and my changes are of no use. Things were perfect with .Net 1.1 but .Net 2.0 has this issue. – Pawan Kumar May 22 '12 at 11:32
  • Well, I can't tell how you are loading the config file. But you need to save and load it somewhere other than under Program Files. – David Heffernan May 22 '12 at 11:33