ShellExecAsUser plug-in

From NSIS Wiki
Revision as of 15:16, 30 September 2011 by Installer32 (talk | contribs) (ShellExecAsUser plug-in)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Description

Execute the specified program using ShellExecute in non-admin context.

The ShellExecAsUser plug-in is intended for installers that run with admin rights, but need to execute something as a normal non-elevated process.

This is accomplished by having Explorer launch the application on the installer’s behalf (http://brandonlive.com/2008/04/27/getting-the-shell-to-run-an-application-for-you-part-2-how/).

As such it's a light alternative to UAC plugin.

Usage

Syntax is exactly the same as NSIS built in ExecShell command:

ShellExecAsUser::ShellExecAsUser action command [parameters] [SW_SHOWDEFAULT | SW_SHOWNORMAL | SW_SHOWMAXIMIZED | SW_SHOWMINIMIZED | SW_HIDE]

Note that action is usually "open", "print", etc, but can be an empty string to use the default action. Parameters and the show type are optional. $OUTDIR is used for the working directory. When installer process is non-elevated (e.g. executed on Windows XP, or UAC is disabled, etc), defaults to ShellExecute method.

Example:

 ShellExecAsUser::ShellExecAsUser "open" 'http://www.google.com/' 

Download

ShellExecAsUser.zip (18 KB)