Archive: Use !define conditionally


Use !define conditionally
  I want to use the !define UMUI_ALTERNATIVESTARTMENUPAGE_SETSHELLVARCONTEXT statement only if the current user has administrator priviledges. How is this possible?

Thanks,
Yves


You can't set SetShellVarContext based on what privileges are available?


I can and I do, but that only influences some directory variables not the page displayed by UMUI...

I am even using

!define UMUI_DEFAULT_SHELLVARCONTEXT $UMUI_DEFAULT_SHELLVARCONTEXT 

>
and then setting $UMUI_DEFAULT_SHELLVARCONTEXT conditionally, but this method doesn't work for

define UMUI_ALTERNATIVESTARTMENUPAGE_SETSHELLVARCONTEXT 

>
as it has no argument.

Most probably you'll have to edit the UMUI header file.


That's what I wanted to avoid...


I would try to implement this feature soon.
The method that I will use is to try to create a file in the Program Files to determine if the application has administrator rights and if this is not the case, disable radio buttons on the start menu page.
Unless you have a better method for determining the level?


I am currently using:


xtInfoPlugin::IsAdministrator

Pop$0
StrCmp$0 "true"
Something like:

false 

>
would thus be enough. You could make such an argument optional and thus not break backward compatibility.

Best Regards,
Yves

Originally posted by SuperPat
Unless you have a better method for determining the level?
UserInfo::GetAccountType from UserInfo.dll already included in NSIS. http://nsis.sourceforge.net/IsUserAdmin

Originally posted by redxii
UserInfo::GetAccountType from UserInfo.dll already included in NSIS. http://nsis.sourceforge.net/IsUserAdmin
I think this function does not return the right answer on a windows Vista/7 with a administrateur account if the RequestExecutionLevel is set as user?

http://nsis.sourceforge.net/Examples...o/UserInfo.nsi


Well, even if the account is an Administrator in UAC approval mode, if they don't elevate the setup they can't create shortcuts for all users anyway, only for themselves and it's as if they are non-admins.

UserInfo returns the right answer for what privileges the installer has. You don't want to use GetOriginalAccountType to see that they are really an administrator, the installer isn't running elevated, and assume that the context should be set to 'all'.


I have tested this on Vista. If "RequestExecutionLevel user" is set, UserInfo::GetAccountType will not return Admin, but the user has no write acces to Program Files for example, so the answer is correct as redxii says.

Best Regards,
Yves


Very good


Problem solved in today's release. Thanks for your quick development!

Best Regards,
Yves