Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check if user has Administrator rights 2

Status
Not open for further replies.

dgschnei

Technical User
Nov 26, 2002
14
0
0
US
How can find out if the user has administrator rights using VB and/or VBscript?

If the user does not have administrator's access rights, I simply want to display a message and quit.

Thanks

PS:
I can get the user's name and computer's name using
VBA.Environ("USERNAME"), Function GetUserName using advapi32.dll, Function GetComputerName using kernel32...
 

To do this (on win2k) you will need to use the NetLocalGroupGetMembers API.

Good Luck

 
You could also use the undocumented IsNTAdmin API.

Private Declare Function IsNTAdmin Lib "advpack.dll" (ByVal dwReserved As Long, ByRef lpdwReserved As Long) As Long

msgbox "Are you an Administrator? " & CBool(IsNTAdmin(ByVal 0&, ByVal 0&))


Rob
 
Thank you for your help.

It works for me, you have been of great help.

It is a very good forum, I will let people know about it.

It seems you guys saved my life [thumbsup2]

:O)
 
I've read your conversations,it's really a great help! But I want to ask if the undocumented IsNTAdmin API will work for other Windows Versions.Will it Work???

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top