Developing Apps with Administrator Rights in Delphi

Roddy picture Roddy · May 24, 2011 · Viewed 12.3k times · Source

I'm using D2010 under Windows 7 to write an app that seems to require admin rights (I think because it uses COM to communicate with a third party .exe, which also requires admin rights).

I've added the manifest resource as required, but when I try to debug the app from the IDE, it reports

"Unable to create process. The requested operation requires elevation"

...and it won't run. If I run Delphi as administrator, then my app runs correctly, but this feels like a dangerous brute force approach, especially as most of the apps I develop don't need admin privileges.

Is there any way of getting Delphi to prompt for elevation just when I run my app, rather than having the whole IDE run elevated?

Answer

Phil Rogers picture Phil Rogers · Nov 13, 2012

UAC also catches any application that has the words "setup", "update" or "install" in their name or in many of the Version Resource fields. (Company name, App Name, Description etc. It considers any such application to be a potential "installer" application and therefore must be run with Admin privileges.

Sounds crazy, but it's true. See the "Installer Detection" section in this document.

You can get around this by including a manifest that says that it doesn't need admin privileges.