administrator permissions RRS feed

  • Question

  • I need  to write to file that only admin permision.

    How Can do this?

    Monday, September 9, 2019 3:11 PM

All replies

  • You will need to run the program that writes the file with elevated permissions.

    If you only need to do it once, you can right-click on your program's executable and find in the context menu the option "Run As Administrator". Once run in this way, your program should be able to write the file.

    If you need a more permanent solution, go to the project in Visual Studio, select "add new item", and add a Manifest file (app.manifest). Edit the file in visual studio and examine the comments inside. You will see the option to run as administrator. Configure it in accordance with the comments. The app.manifest should be added automatically by Visual Studio as the manifest for the program in the Project properties. But check that it is added there in case it's missing.

    Once you've done this, the program will run as administrator every time that you launch it. Of course, if it is launched by someone who is not an administrator, it will ask for the administrator credentials. There is no workaround for this other that changing the permissions of the file.

    Monday, September 9, 2019 3:49 PM