Admin Detection

Scott Rossi scott at tactilemedia.com
Wed Aug 13 15:22:00 EDT 2003


Recently, "xbury.cs at clearstream.com"  wrote:

>> I'm trying to detect whether or not the current Windows user has Admin
>> rights.  If the only way to determine this is to attempt to create a file,
>> what is the best path to use?

 
> on NT4 or W2K only... (it would be nice if someone posted the osx and linux
> variants ;) 
> 
> echo %username% 
> will give you the current user name.
> 
> Then, put the result in comparison with
> c:\net localgroup
> Choose the administrator group
> net localgroup "administrators"
> you should see your user name in there.
> 
> Alternatives: 
> In a NT domain, the local admin may be useless!
> You can find the admins in net group "domain admins" -- but only from the
> PDC... 
> Unless you have EnterpriseAdmin (obsolete I believe) -- more below...
> ...

Thanks for the suggestions.  Using the posted code verbatim on XP appeared
to fail (the handler function returned true while logged in as guest) but I
may not have set up everything correctly as in your post.

Alternatively, it seems that attempting to write to the registry is one way
to test admin privileges: writing to the registry returns an error when
logged in as guest.  So the only issue is a leftover empty key in the
registry once I am done admin testing (unless the latest version of Rev has
added some way to remove keys from the registry).

Regards,

Scott Rossi
Creative Director
Tactile Media, Multimedia & Design
-----
E: scott at tactilemedia.com
W: http://www.tactilemedia.com




More information about the metacard mailing list