0

Windows executable using RegCreateKeyEx() does not prompt for UAC admin rights and fails?

How to make my Windows executable prompt for admin rights?

I've created a Windows application that needs to create a key in the Windows registry.

However, this call fails when double-clicking on the executable, even thus I'm logged in as admin. But, if I explicitly run the program as admin (by right-clicking) everything works just fine.

Why doesn't UAC prompt for the required rights? If I've misunderstood something, how can I fix this by other means?

1 Answers1

-1

You can't, but you can restart the application with admin rights. Use the ShellExecute command:

ShellExecute(0, "runas", "yourexe.exe", 0, 0, SW_SHOWNORMAL);

The "runas" bit is the part that gives you admin.

c z
  • 7,726
  • 3
  • 46
  • 59