Windows version outside Section or Function
Hello, everybody.
Question is in the title. If I understand existing plugins allow to get Windows version is the section or function.
Is there any macro which allows to do this outside them?
Archive: Windows version outside Section or Function
Windows version outside Section or Function
Hello, everybody.
Question is in the title. If I understand existing plugins allow to get Windows version is the section or function.
Is there any macro which allows to do this outside them?
If you're outside a section or function, you're talking about compiletime. So you want to get the windows version of the machine where your installer is being compiled? Why not just harcode it into the script - you should know your own windows version, after all.
Anyway, you'll have to do it outside of the compiler, for example using the !system command: http://nsis.sourceforge.net/Docs/Chapter5.html#5.1.12
Well, actually I need to define execution level depending on the Windows version end user runs my installer on.
For now I can't test but will it work for example like this?
!ifdef WINVER_7
RequestexecutionLevel user
>!else !ifdef WINVER_VISTA
RequestexecutionLevel highest
>!else WINVER_XP
RequestexecutionLevel admin
>!endif
No it will not because !ifdef etc. are compile time conditionals. Also RequestExecutionLevel is a compile time instruction - you cannot change it at run time. If you want a different RequestExecutionLevel you will just have to have a different build for targeting that OS.
Stu
Thank you, Stu.
Sad, but very clear.
But why? Why treat Vista and 7 differently? (And RequestexecutionLevel has no effect pre Vista) And when UAC is off they are both pretty similar to XP...
If I use UAC plugin I request execution level "user" for Win7 and at the same time I have to use "admin" level for XP. That's why I wanted to choose this level first of all.
Originally posted by oldfriendWell, like I said, it has no effect on XP. You are probably doing something wrong if the OS version is so important. Remember that not everyone is admin on XP either...
If I use UAC plugin I request execution level "user" for Win7 and at the same time I have to use "admin" level for XP. That's why I wanted to choose this level first of all.
You can use the UAC plugin to elevate your installer on any NT version after 2k. Just set executionlevel user like you're supposed to, then elevate your installer at runtime if there's a need for it.
Setting requestedexecutionlevel to admin on XP does absolutely nothing: Only Vista and newer use the executionlevel setting (and even then, only if UAC is turned on).
So what is the principal difference between "RequestExecutionLevel admin" and using UAC plug-in except that fact that UAC plug-in could be used and turned on on any stage (almost) of installer execution?
The UAC plugin allows you to execute instructions as the user (not the administrator) but I'm guessing it is not something you should be looking at. IMHO you need to figure out if you are creating a all users (admin) OR a single user installer (user) and go from there.
I agree with Anders, but to answer your question: Using request admin means that Vista and higher (if UAC is enabled on those OSes) will automatically pop an admin request. That's all it does, nothing more, nothing less. But anything older than Vista (and anything with UAC turned off) will not do anything with the request, so you still have to check for admin access manually using the userinfo plugin. This is the proper way to do things: Either make an all-user installer at admin level to $PROGRAMFILES and HKLM (with both request admin and userinfo plugin verification), or make a single-user installer at userlevel to $(LOCAL)APPDATA and HKCU (with request user).
Like you said, using the UAC plugin will allow you to elevate at any point in the installation process. This allows you to circumvent the above choice, by doing things both at userlevel and adminlevel at the same time. This solution is however both very complex and quite error-prone. It is definitely not something you should be using unless you're A) overzealous, B) a masochist, or C) extremely sure of yourself. Or, preferably, D) all of the above.
Thank you, guys. Thank you Anders and MSG. You helped me very much. Thank you for your time and attention.