admin right to set up
How can I make sure the user installing my software has admin rights as i am making setup using Nsis scripting language, and should applicable for all OS (Windows,XP).
Archive: admin right to set up
admin right to set up
How can I make sure the user installing my software has admin rights as i am making setup using Nsis scripting language, and should applicable for all OS (Windows,XP).
1) In .onInit, use the UserInfo plugin to verify admin access. If it's not admin, throw a messagebox error and quit.
2) To allow Vista/7 UAC to handle things more gracefully, you may also want to add 'requestexecutionlevel admin' to your script.
Thanks MSG for your reply
how can i use the userinfo plugin ,can you provide me any link or any code help where i can get all the details
Hmm... Try googling for 'nsis userinfo plugin'. Also, the userinfo plugin comes shipped with NSIS, so check NSIS\Examples\UserInfo\UserInfo.nsi .
As you can see, all the information is out there. You just need to be brave enough to search for it, before asking others for the solution.
Say Anders, does Windows automatically set an errorlevel if UAC elevation fails?
Originally posted by MSGErrorlevel is really a DOS/batch thing, windows processes have exit codes.
Say Anders, does Windows automatically set an errorlevel if UAC elevation fails?
Err yeah, exit code. Very informative, thank you!
Thanks Anders for your help
i made changes it and run on both XP and Vista system but only the difference is that in Xp message box is shown "Administrator rights required!" but in vista no message box is coming with the same code,as you have provided in the link waiting for the reply
============================================
Outfile "RequireAdmin.exe"
RequestExecutionLevel admin ;Require admin rights on NT6+ (When UAC is turned on)
!include LogicLib.nsh
Function .onInit
UserInfo::GetAccountType
pop $0
${If} $0 != "admin" ;Require admin rights on NT4+
MessageBox mb_iconstop "Administrator rights required!"
SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
Quit
${EndIf}
FunctionEnd
Section
SectionEnd
Originally posted by MSGThanks MSG
Hmm... Try googling for 'nsis userinfo plugin'. Also, the userinfo plugin comes shipped with NSIS, so check NSIS\Examples\UserInfo\UserInfo.nsi .
As you can see, all the information is out there. You just need to be brave enough to search for it, before asking others for the solution.
Originally posted by shazia.parveenThen that probably means that you're already an admin user, on your Vista PC.
in Xp message box is shown "Administrator rights required!" but in vista no message box is coming
Hi Msg actually after running the setup with no admin right account only it is showing the login page for administrator to login for administrative right it is not showing the message box "Administrator rights required!" in Vista as it was showing in Xp.
Actually when i turned off UAC in case of Vista then it is showing the message box "Administrator rights required!" but when UAC is turned on in case of Vista no message box is coming only it is showing the login page for administrator .
In no admin right account when i turned off UAC in case of Vista then it is showing the message box "Administrator rights required!" but when UAC is turned on in case of Vista no message box is coming only it is showing the login page for administrator . waiting for the reply.
It's doing exactly what it should - this is how UAC is designed to operate. There is nothing you can do about it.
If you always want the messagebox, use "RequestExecutionLevel user" (There is no reason to do this, and the exe will not get the UAC icon overlay)
Not only is there no reason to do that, but it also makes things worse: Many users don't know how to 'Run as Admin', because they rely on UAC to do the elevation for them. If you request user, and then enforce admin, many people won't understand how to use the installer.
Thanks so much for your support