Run as Administrator Registry

0

0

I made a program with a message box that writes to the registry at

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

and it writes this:

Value Name: Program
Value Data: C:\Users\Noah\Documents\Visual Studio 2015\Projects\Program\Program\bin\Debug\Program.exe

The program runs when I restart but it needs to run as administrator. Can I write to the registry to make it do this?

Noah

Posted 2016-07-24T21:12:17.203

Reputation: 13

Answers

2

You have placed the registry key in the LOCAL_MACHINE hive. The Run subkey programs will all be executed using the SYSTEM user, and for that you need Administrative privileges. If your current user is local admin, these programs will run normally.

If not, a prompt will popup asking for administrative approval (UAC)

If you do not want to have this prompt, make the program run as user instead.

A user can always write to the CURRENT_USER registry key without requiring administrative approval. Placing your run key there will not give a UAC prompt at boot time, nor does the user has to run the program as administrator to make this change.

Do note that at runtime, the program is not running with administrative privileges, but as regular user, so the program is limited in what it can do.

LPChip

Posted 2016-07-24T21:12:17.203

Reputation: 42 190