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
NSIS request admin/user depend on registry
7 posts
tried to make section on top result:
Error: command RequestExecutionLevel not valid in Section
Error: command RequestExecutionLevel not valid in Section
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).
Right. So there is no way complete my mission right? 🙁
"RequestExecutionLevel highest" will elevate administrators and do nothing for normal users. It is safe to write to HKCU and $LocalAppData in this mode.
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.
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.
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.