|
![]() |
#1 |
Junior Member
Join Date: Feb 2014
Posts: 27
|
NSIS request admin/user depend on registry
Hello,
Can someone help me a bit with NSIS v3.04? I want NSIS to check registry and depend on registry value RequestExecutionLevel user or admin. I'm moving users from ProgramFiles(only DLL stored) to localdisk folder to make sure they wont need admin rights on next and future updates, but not everyone installs it regularly so I created registry value as mark. Code I'm using: ReadRegStr $INSTDIR HKCU "Software\....." "my registry value as string" StrCmp $INSTDIR "" 0 NoAbort MessageBox MB_OK "messgebox for testing purpose" RequestExecutionLevel admin When I tried to put on top but got message: Error: command ReadRegStr not valid outside Section or Function When i tried to use it in Function .onInit : Error: command RequestExecutionLevel not valid in Function |
![]() |
![]() |
![]() |
#2 |
Junior Member
Join Date: Feb 2014
Posts: 27
|
tried to make section on top result:
Error: command RequestExecutionLevel not valid in Section |
![]() |
![]() |
![]() |
#3 |
Major Dude
Join Date: May 2005
Location: New Zealand
Posts: 893
|
RequestExecutionLevel is an installer attribute, the compiler resolves it when the script is compiled (all it does is add a request for admin rights into the manifest of the installer).
"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me) NSIS 3 POSIX Ninja Wiki Profile |
![]() |
![]() |
![]() |
#4 |
Junior Member
Join Date: Feb 2014
Posts: 27
|
Right. So there is no way complete my mission right?
![]() |
![]() |
![]() |
![]() |
#5 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,333
|
"RequestExecutionLevel highest" will elevate administrators and do nothing for normal users. It is safe to write to HKCU and $LocalAppData in this mode.
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#6 |
Junior Member
Join Date: Feb 2014
Posts: 27
|
For migration I will need admin rights as I need re-deploy .DLLs to new location. But the next updates won't require it. And I just wanted to make sure if anyone skips migration update the next one update will automatically check and ask Admin rights to make migration first. Not sure or I wrote correctly understandable :F
I did not realized that admin rights will be "static" on setup. Will find other solution. As always thanks JasonFriday13 and Anders for fast response. |
![]() |
![]() |
![]() |
#7 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,333
|
You can bundle a small installer that asks for elevation, extract and run it from $pluginsdir if required. It can do the HKLM & ProgramFiles cleanup.
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
|
Tags |
uac |
Thread Tools | Search this Thread |
Display Modes | |
|
|