Archive: How to use the UAC Plugin ?


How to use the UAC Plugin ?
  Hi everyone, first of all I'll ask you to excuse my English (yes, I'm French ;) ).

I've got some troubles to make the UAC Plugin working...

I've read the following page : http://nsis.sourceforge.net/UAC_plug-in

And after having downloaded the zip file and read the examples given in it, I compiled them but none succeeded...

Then I just tried to insert the code given in the page in my .nsi :
First :

RequestExecutionLevel user 

>
at the beginning of the script,

Then

'UAC.nsh' 

And to finish

.

Function .OnInit

UAC_Elevate:
UAC::RunElevated
StrCmp 1223$0 UAC_ElevationAborted ; UAC dialog aborted by user?
StrCmp 0 $0 0 UAC_Err ; Error?
StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper?
Quit

UAC_Err:
MessageBox mb_iconstop "Unable to elevate, error $0"
Abort

UAC_ElevationAborted:
# elevation was aborted, run as normal?
MessageBox mb_iconstop "This installer requires admin access, aborting!"
Abort

UAC_Success:
StrCmp 1 $3 +4 ;Admin?
StrCmp 3 $1 0 UAC_ElevationAborted ;Try again?
MessageBox mb_iconstop "This installer requires admin access, try again"
goto UAC_Elevate

FunctionEnd
>
with my own functions.

But when I try to compile, I've got the following error :

Function: ".OnInit"
Invalid command: UAC::RunElevated
Error in script "C:\Users\Me\MyFolder\MyScript.nsi" on line 156 -- aborting creation process

I think I've missed something, the file UAC.nsh is in the same directory as the script (MyFolder).

Can anybody try to help me please ? :cry:

Put UAC.dll in the Plugins folder.

Stu


Thanks for you answer,

I'm going to test and let you know...


Originally posted by Afrow UK
Put UAC.dll in the Plugins folder.

Stu
Hi

In the package there's actually two UAC.dll, one in a A/ directory and one in U/.
I put the A one in Plugins (for no worthwhile reason) and when the installer asks for elevation it does so with a weird (random/temp) name. Should I have used the one in U/ (and does anyone know what the difference is ?)

A=ansi (normal official nsis)
U=unicode (3rd party nsis version)

The installer command should look something like: c:\path\installer.exe /UAC:1234 /NCRC

The uninstaller on the other hand might be in %temp% and have a weird name, but thats how NSIS does it