2

I am currently coding a WPF project. The project is a sort of Task Manager program. Inside of the project, there are methods that take real-time PC data (temp, frequency, etc). However, some of the methods in the project require administrator privileges, so that the program can have access to the different values/data from the PC.

The problem at hand is that the program asks for these permissions every time the program is run. While I know this is just a personal preference, I would like to make the program only ask for the said privileges at installation/first run, so that the user does not have to authorize their permission every time.

Just to be clear, this is not a question about how to get the administrator privileges in general. I know that there is the option to manipulate the app.manifest file. This question is only pertaining to keeping the set administrator privileges programmatically, or through other means such as visual studios.

(Also, the program uses NSIS as an installer, if this is at all helpful)

Thanks

EDIT:

Looking back at this question, it was a pretty stupid one. It was just due to my sloppy/lazy coding.

Aaron
  • 97
  • 12
  • I severely doubt UAC would go for this scheme – BradleyDotNET Jul 26 '18 at 18:29
  • did you [check this out](https://stackoverflow.com/a/22802253/1132334) already? [and this](https://superuser.com/a/506125/698590) – Cee McSharpface Jul 26 '18 at 18:30
  • @BradleyDotNET What do you mean? – Aaron Jul 26 '18 at 18:30
  • As the answer states the whole point of UAC is to let user's know when programs are running with elevated permissions. You are trying to bypass this. – BradleyDotNET Jul 26 '18 at 18:44
  • Yes, but I don't understand the point of calling this a scheme, or commenting without adding to conversation/solution of a valid question. This question isn't "How can I infect PCs with a WPF program", I am looking to appeal to the common user by making the program as usable as possible. In theory, this is no different than the user changing the .exe's permissions in it's properties. I am asking so that the program can achieve those same results for the general user, who most likely does not know how to change the said properties manually. – Aaron Jul 26 '18 at 18:56
  • What about [Registering your app in Task Scheduler?](https://superuser.com/questions/770420/schedule-a-task-with-admin-privileges-without-a-user-prompt-in-windows-7) – Avestura Jul 26 '18 at 19:29

2 Answers2

3

That is not possible because the purpose of UAC Prompt is to create awareness for the user so they know that they are allowing admin privileges to the software.

I Do not really advise you to skip the step of the prompts.

You can not do it directly but you can indirectly , if you can write a code to do the following steps here , you can achieve what you asked for.

Amir
  • 721
  • 6
  • 21
  • Great. Thanks for the response! I was wondering though, why would you not recommended skipping the steps of the prompts? – Aaron Jul 26 '18 at 18:38
  • 1
    Because you do not really want your clients to suspect.I Would advise you to just use the manifest file and add an option in the software itself which asks for trust from the user for the software and if they allow that by performing an action such as ticking the checkbox or agreeing then you can do the shortcut one but if they don't then just let it be as it is. – Amir Jul 26 '18 at 18:39
  • Ah, I see. So you would advise against this, even though the program asks for permission at the first instance of the programs installation? – Aaron Jul 26 '18 at 18:41
  • 1
    least cares for the prompt which is shown while installing because its required to perform installation in most cases. but if its shown everytime the user is opening the application then they start having thoughts if they are smart enough that the program is using admin privileges for something they do not know. i am not against , this might be really annoying for some user but its good if you let them know what you will do if they tick the checkbox or allow the permissions once and for all by showing them some agreement, you will have an answer if by chance you get in legal s even by mistake. – Amir Jul 26 '18 at 18:47
  • That makes sense. Considering your advice, I think the best option might be to just guide the user on how to change the .exe's properties manually if they wish to do so. – Aaron Jul 26 '18 at 18:58
  • I Do not think anyone will follow that just to reduce a step which takes 0.1 secs to click on a button 'yes'. either make it automatically after they have agreed or just leave it , i hope you understand what i mean. – Amir Jul 26 '18 at 18:59
1

Windows is a secure operating system. If the user is not an administrator: then you don't get to control that.

What would your application have done under Windows XP?

  • Would it have crashed?
  • Would you have refused to run?
  • Would you have told the user that they need to be an administator?

Is there no lesser mode you can use that can still give the user useful information? After all, Process Explorer is still able to run and give me all kinds of useful information about processes on the computer.

But if the user is a standard user, you have no way to change that at install time.

Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219