Archive: IsUserAdmin script


IsUserAdmin script
Hi all

I did try to make the "IsUserAdmin" to check if the user is anmin or not, if not the script exit's

can somone check the script and if necessary correct it so it is ok?

thanks

the link to orginal script:
http://nsis.sourceforge.net/IsUserAdmin


You shouldn't modify the function. Simply call it, and act as you wish according to its result. For example:

!include LogicLib.nsh
Function .onInit
Call IsUserAdmin
Pop $0
${If} $0 != "true"
MessageBox MB_OK|MB_ICONSTOP "not admin"
Quit
${EndIf}
FunctionEnd

thanks


Originally posted by kichik
You shouldn't modify the function. Simply call it, and act as you wish according to its result. For example:
!include LogicLib.nsh
Function .onInit
Call IsUserAdmin
Pop $0
${If} $0 != "true"
MessageBox MB_OK|MB_ICONSTOP "not admin"
Quit
${EndIf}
FunctionEnd
i tryed this way but it doesed work for me,if i'm loged on as admin the MessageBox pops up.

i'm i doing somting wrong?

Put $0 in a MessageBox and see what it says.

-Stu


hello

i did put in the $0 and the messageBox is emty


Can you post the exact code snippet that you are using?
I cannot find an exit point in the function that returns an empty value.

-Stu


Looking at the script that you sent me... it is really quite obvious. You have commented out some key parts of code at the end of the function like so:
;Pop $R2
;Pop $R1
;Exch $R0

You really shouldn't modify functions unless you are 100% sure you know how they work. Uncomment those three lines.

-Stu


hmmm... wierd i did use them to pop the value in the messagebox in line 214

but... it works ;)
thanks :up: