Skip to content
⌘ NSIS Forum Archive

How to create a shortcut with "Run as administrator" checked

8 posts

Voxen06#

How to create a shortcut with "Run as administrator" checked

Hi,

I need NSIS to create my application's shortcut with "Run as administrator" checked by defaut, because otherwise the application auto-update feature doesn't work (updated .exe cannot be written to C:\Program Files).

I tried to set RequestExecutionLevel admin but it doesn't help.

Is it possible to do that from NSIS? I really don't want to ask customers to manually set this checkbox manually after the installation.

Thanks for your help!
Afrow UK#
http://www.microsoft.com/resources/d....mspx?mfr=true
http://www.microsoft.com/resources/d....mspx?mfr=true

Stu
Voxen06#
I'm not sure this is what I need.

The "runas" will ask for administrator password each time the application is launched, right?

I need that application runs as administrator when the user double click on the shortcut, exactly like if he does check the "Run as administrator" from the shortcut properties.
Voxen06#
Thanks for your help, but it still doesn't make it.

I tried to create a shortcut with this:
runas /user:ComputerName\administrator "C:\Program Files\App\App.exe"

When I double click the shortcut, it opens a command line window that asks for my password.

The shortcut is a half part of the problem, because my application is also started with Windows (from the registry's Run key) and it has to start with administrator privileges too.
Afrow UK#
I came across this:
Use RunAs utility to execute a program from command line using a different user account. Advanced options available. RunAs is similar to the Windows 2000/XP/2003/Vista native RunAs utility, but it has some distinct features making it much more usable than the native version


Stu
Anders#
sample code @ http://blogs.msdn.com/oldnewthing/ar...9/6801084.aspx hopefully someone can convert it to system plugin code
grzech#
Here is the full code with error handling I wrote for that:
Are you a developer who uses NSIS to distribute your application? Are you a Winamp plug-in developer who wants to use NSIS to distribute your plug-in? Have suggestions for other people like you? This is the place.


It's C++ though. I put that in our dll and simply executed upon successful install using rundll32.


PS. Sorry for bumping an old thread - mistake due to message filtering.