sixcode
18th December 2005 15:05 UTC
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
kichik
20th December 2005 18:02 UTC
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
sixcode
20th December 2005 19:33 UTC
thanks
sixcode
21st December 2005 19:05 UTC
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?
Afrow UK
22nd December 2005 10:32 UTC
Put $0 in a MessageBox and see what it says.
-Stu
sixcode
22nd December 2005 19:02 UTC
hello
i did put in the $0 and the messageBox is emty
Afrow UK
22nd December 2005 21:37 UTC
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
Afrow UK
24th December 2005 17:27 UTC
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
sixcode
24th December 2005 18:35 UTC
hmmm... wierd i did use them to pop the value in the messagebox in line 214
but... it works ;)
thanks :up: