1

I am trying to write my software so that it has administrator rights. Because it has to create files and be able to delete them, But if it is not started by right clicking on it, and clicking on run as administrator it is blocked from doing so.

Any solution would be great.

I did manage to find the following pages. But cannot make sense of it:

Update

I'm trying to read files from the program files directory, and write them elsewhere.

Community
  • 1
  • 1
user3271392
  • 149
  • 2
  • 12
  • Where are you writing these files? – David Heffernan Mar 28 '14 at 06:50
  • @davidheffernan C:\Program Files and C:\Program Files\my applcation\ – user3271392 Mar 28 '14 at 06:59
  • @davidHeffernan i am completely lost on that page, they seem to begin in the middle. I do not even know where to start – user3271392 Mar 28 '14 at 07:00
  • 1
    My advice is to stop writing to the program files directory. Then you won't need to add the manifest. – David Heffernan Mar 28 '14 at 07:02
  • @davidHeffernan Ok but i do zip some files from the program files directory(not files i can move). Wont my program be blocked from gaining access to them then? – user3271392 Mar 28 '14 at 07:04
  • You cannot write there. But why do you want to write there. Write files in a location where you have rights. Users will soon get fed up of your program's UAC prompt. – David Heffernan Mar 28 '14 at 07:07
  • As for the manifest. Do you know what one is? Do you know what an embedded resource is? If not then you first need to do some reading so that you understand all this. – David Heffernan Mar 28 '14 at 07:09
  • @DavidHeffernan No i do not know, i have never worked with it. And i do not want to write there, i want to read from there and write to another location. Will i be blocked or can i read from there? – user3271392 Mar 28 '14 at 07:14
  • You can read from there fine. I suggest that you edit the question to include this new information. – David Heffernan Mar 28 '14 at 07:19
  • Remember that not every user can run with elevate privileges. Your program will run if and only if a user can get those privileges, but not for "normal" users. – Mad Hatter Mar 28 '14 at 08:01

1 Answers1

2

It transpires in the comments that you are trying to read from the program files folder rather than write to it. In which case your program does not need elevation and can run as standard user. You do not need to add the UAC requireAdministrator manifest.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490