Old 29th September 2004, 01:07   #1
kio
Junior Member
 
Join Date: Sep 2004
Posts: 1
administrator check

Has anyone the isadmin.dll?
I searched everywhere and can't find it..
I really need it.

also
Is there a registry key that determines that if the current user logged on is an Administrator or not?

Something like e.x.
if the current user is an admin then the key will be 1
if the current user is not an admin the key will be 0

or an environmental variable?
kio is offline   Reply With Quote
Old 29th September 2004, 01:39   #2
pengyou
Major Dude
 
Join Date: Mar 2003
Posts: 571
Try the UserInfo plugin which comes with NSIS. There is an example script in the Contrib\UserInfo folder.
pengyou is offline   Reply With Quote
Old 29th September 2004, 05:34   #3
JeronimoColon
Junior Member
 
Join Date: Sep 2004
Location: New York City
Posts: 39
There is an undocumented Windows API call for this in the shell32.dll. As part of the Microsoft settlement Microsoft was force to expose a portion of them. One I'm referring to is: ordinal# 680 a.k.a. IsUserAnAdmin.

It exist, I believe, in all NT based platforms. I remember only verifying its existence and it working on NT4 and up.

The bad news is:
It does not contain a function name - only an ordinal#. I believe Microsoft began including the function name in XP, but I don't know if it was always there or introduced in a later service pack.

This is how you would call it in XP using its function name:
System::Call 'shell32::IsUserAnAdmin(v)i .r1'

Unfortunately, I don't believe you can call functions by ordinals using the System.dll plugin - though - I think it would be a nice feature to have included in a future revision to the plugin.

The good news is: You could create your own plugin to call the function via its ordinal yourself.

I hope this was informative if nothing else...

jc3
JeronimoColon is offline   Reply With Quote
Old 29th September 2004, 10:46   #4
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
code:
System::Call "kernel32::GetModuleHandle(t 'shell32.dll') i .s"
System::Call "kernel32::GetProcAddress(i s, i 680) i .r0"
System::Call "::$0() i .r0"
DetailPrint "is admin? $0"


NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 30th September 2004, 04:52   #5
JeronimoColon
Junior Member
 
Join Date: Sep 2004
Location: New York City
Posts: 39
kichik,

You never seize to amaze...



jc3
JeronimoColon is offline   Reply With Quote
Old 1st October 2007, 10:52   #6
drmabuse
Junior Member
 
Join Date: Oct 2007
Location: austria
Posts: 1
Post just packed above into a function for less advanced users

code:


Function CheckAdminRights
System::Call "kernel32::GetModuleHandle(t 'shell32.dll') i .s"
System::Call "kernel32::GetProcAddress(i s, i 680) i .r0"
System::Call "::$0() i .r0"

IntCmp $0 0 isNotAdmin isNotAdmin isAdmin
isNotAdmin:
DetailPrint "Missing Administrator Rights !!!"
messageBox MB_YESNO|MB_DEFBUTTON2 "Die aktuellen Benutzer-Rechte sind zu gering!$\r\
Für die Installation werden Administrator-Rechte benötigt!$\r\
um Bibliotheken (.dll-files) zu registrieren.$\r\
$\r\
Im Fall eines Updates können die aktuellen Rechte dennoch ausreichen.$\r\
$\r\
Soll die Installation ohne Administrator-Rechte fortgesetzt werden ?" IDYES isAdmin
quit

isAdmin:
DetailPrint "Administrator Rights granted"

FunctionEnd
drmabuse is offline   Reply With Quote
Old 4th October 2007, 13:17   #7
fishweasel
Junior Member
 
Join Date: Nov 2006
Posts: 19
I use the following for validation of Administrator user
(not sure where i got it from)

code:
ClearErrors
UserInfo::GetName
IfErrors Win9x
Pop $0
UserInfo::GetAccountType
Pop $1
StrCmp $0 "Administrator" 0 +3 ;
Goto done
StrCmp $1 "Power" 0 +3
MessageBox MB_OK 'You Must be logged in as Administrator!'
Quit ;
StrCmp $1 "User" 0 +3
MessageBox MB_OK 'You Must be logged in as Administrator!'
Quit ;
StrCmp $1 "Guest" 0 +3
MessageBox MB_OK 'You Must be logged in as Administrator!'
Quit ;
MessageBox MB_OK "Unknown error"
Quit ;

Win9x:
# This one means you don't need to care about admin or
# not admin because Windows 9x doesn't either
MessageBox MB_OK "Error! This DLL can't run under Windows 9x!"

done:



Fish
fishweasel is offline   Reply With Quote
Old 4th October 2007, 13:23   #8
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
fishweasel, you got this from Examples\UserInfo which is the examples folder for the plug-in written exactly for this purpose.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 31st July 2013, 23:51   #9
didava
Member
 
Join Date: May 2007
Posts: 98
Hi
It does not work in Windows Seven

PHP Code:
Function .onInit

##############################
# GetAccountType             #
##############################
ClearErrors
UserInfo
::GetAccountType
IfErrors 
+3
Pop 
$0
StrCmp 
$"Admin" begin
MessageBox MB_OK
|MB_ICONSTOP|MB_TOPMOST "This user is not an administrator!!"
Quit
begin

PHP Code:
Why؟
Where is the problem؟
StrCmp 
$"Admin" begin
MessageBox MB_OK
|MB_ICONSTOP|MB_TOPMOST "$0"

A message window MessageBox is the Just type A

Can you please write me a code sample
!! 
Thanks For Hellp- if
didava is offline   Reply With Quote
Old 1st August 2013, 01:29   #10
demiller9
Senior Member
 
Join Date: Mar 2006
Location: Dallas
Posts: 462
I compiled the example program that comes with NSIS and it ran fine on my Windows 7 system. (I added "RequestExecutionLevel user" to stop UAC from asking me to elevate before it executed the test program.) With elevation, it shows that I am Admin. Without elevation it shows that I am User.

Take another look at the example program.
demiller9 is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump