Old 22nd July 2019, 06:40   #1
bankeris
Junior Member
 
Join Date: Feb 2014
Posts: 22
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
bankeris is offline   Reply With Quote
Old 22nd July 2019, 06:56   #2
bankeris
Junior Member
 
Join Date: Feb 2014
Posts: 22
tried to make section on top result:

Error: command RequestExecutionLevel not valid in Section
bankeris is offline   Reply With Quote
Old 22nd July 2019, 09:38   #3
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 881
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
JasonFriday13 is offline   Reply With Quote
Old 22nd July 2019, 10:06   #4
bankeris
Junior Member
 
Join Date: Feb 2014
Posts: 22
Right. So there is no way complete my mission right?
bankeris is offline   Reply With Quote
Old 22nd July 2019, 10:41   #5
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,164
"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
Anders is offline   Reply With Quote
Old 22nd July 2019, 11:05   #6
bankeris
Junior Member
 
Join Date: Feb 2014
Posts: 22
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.
bankeris is offline   Reply With Quote
Old 22nd July 2019, 12:11   #7
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,164
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
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
uac

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump