Search code examples
windowswindows-7runas

Set "Run as Administrator" for shortcut automaticlly


In Windows 7, you can set a property of a shortcut to "Run as Administrator", so that the application is invoked with Administrator privileges or the user is asked for an admin account.

I know I can request/force Administrator privileges with a manifest file for my application, but I need to set the privileges for applications that are not mine. As Installer Software I use SetUp Factory 8. It will create a shortcut but doesn't set "Run as Administrator".

So far I set the option with every customer manually after install but that is a lot of work.

How can I set "Run as Administrator" for application shortcuts via a program/script (like editing the shortcut) or in any other way.


Solution

  • You know that you can embed a manifest, but it seems like you don't know you can also have an external manifest. You don't need to compile the executable for this. Just name the file whatever.exe.manifest and put it in the same folder as whatever.exe. If that manifest says requireAdministrator, you'll request elevation on every run. Have your installer copy the manifest wherever it copies the exe.