tenfour
tenfour

Reputation: 36896

How to create a file that doesn't require elevation to edit, when running elevated?

When my app is running elevated and creates a file (using CreateFile), that file requires elevation to be further edited.

How do I create a file that does not require elevation to edit, even if my app is running elevated?

Upvotes: 1

Views: 178

Answers (1)

David Heffernan
David Heffernan

Reputation: 612784

When my app is running elevated and creates a file (using CreateFile), that file requires elevation to be further edited.

That is not correct. What is actually happening, most likely, is that you are saving the file to a directory which has restrictive access rights. For example, the program files directory, or the system directory.

So, there are two ways for your program, when running elevated, to save a file which can be edited by standard user:

  1. Save the file in a location which does not have restrictive access rights.
  2. After saving the file, give it permissive access rights by applying an ACL.

Of these options, the former is usually the correct choice.

Upvotes: 3

Related Questions