Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>Outfile RequireAdmin.exe RequestExecutionLevel admin ;Require admin rights on NT6+ (When UAC is turned on) !include LogicLib.nsh Function .onInit UserInfo::GetAccountType pop $0 ${If} $0 != "admin" ;Require admin rights on NT4+ MessageBox mb_iconstop "Administrator rights required!" SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED Quit ${EndIf} FunctionEnd Page InstFile Section SectionEnd </code></pre> <p>is the basic code I usually recommend to make sure the installer is running as an Administrator.</p> <p>IMHO it does not make sense to prompt for credentials on a custom page unless only parts of the install process requires administrator access and the other part requires access to the users profile. If this applies to you then you should take a look at the <a href="http://nsis.sourceforge.net/UAC_plug-in" rel="noreferrer">UAC plug-in</a> (It is a bit complicated to use and makes it impossible for your exe file to get the shield overlay icon)</p> <p>I don't think the <a href="http://nsis.sourceforge.net/NSIS-RunAs" rel="noreferrer">RunAs plug-in</a> works correctly on Vista+ when UAC is on so trying to get it to work might be a dead end...</p> <p>The <a href="http://msdn.microsoft.com/en-us/library/bb530410.aspx" rel="noreferrer">recommended way</a> to get the shield is to request elevation in the exe manifest, <code>RequestExecutionLevel admin</code> does that. If you don't use <code>RequestExecutionLevel</code> at all in your script your installer <strong>might</strong> be detected as a legacy installer and it will also get the shield overlay.</p> <blockquote> <p>In Windows Vista, if an executable file requires elevation to launch, then the executable's icon should be "stamped" with a shield icon to indicate this fact. The executable's application manifest must mark "requireAdministrator" to designate the executable as requiring a full administrative access token. The shield icon overlay will also be automatically placed on executables that are deemed to require elevation as per the installer detection heuristics. For example, a file named setup.exe will automatically receive a shield icon overlay even if the executable does not have an embedded application manifest.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload