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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to tell if current user has admin privileges?

Status
Not open for further replies.

GDameron

Programmer
Aug 8, 2003
39
US
Win2K: Is there a way for a batch script to find out if the user running it is a member of the Administrators group?

GD
 
You could try having the batch file try to create a file in the root of c: (e.g. ECHO Test Text > C:\TEST.TXT) and the use IF EXIST C:\TEST.TXT to see if the file was created. Since restricted users have only read permissions to the root of c: the file will be missing whereas an Admin user will have the file.

I'm not sure about Power Users (I think have read only rights). Also if another security template has been applied (e.g. compatws) or the rights have been changed manually then this will not work.

Good luck.
 
what your asking might be able to be done, but not easily, like say in an IF statement...
you use the "net localgroup administrators >>member.txt"
on the command line which dumps the output to a text file..
then you could check the txt file to see if the users
(domain\user) name is in the file....if so hes an admin.
i know, not pretty. There maybe another option...you might be able to find out in the registry whether the current user has admin privliges..but i dont know. if you find out let us all know....

hope this helps
chris castelein
architectural designer
shive-hattery
cedar rapids iowa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top