Here is a little command line tool I wrote called ISADMIN. The program runs on Windows 95/98/NT/2000/XP/2003 and up. Just run this little program from the command line and it will tell you whether or not the logged in user has administrative rights. The utility has a silent mode which makes it a perfect tool for installers and batch files. In addition to the tool's output (which is not displayed in silent mode), you can determine whether or not the user has administrative rights based on the error level returned on program exit (errorlevel 0 means that the user has administrative rights). Also note that on Windows 95, 98, and ME, this program will always report that the user has administrative rights.
I've decided to release the source for this program. Feel free to use the program or its source code in any way you wish.
Requirements: Windows 95/98/NT/2000/XP/2003+
You can download the source code from here - isadmin_src.zip 44 KB
You can download the precompiled executable from here - isadmin.zip 38 KB
Jeff (email address hidden) wrote @
This does not seem to work on Vista
Morris Maynard (email address hidden) wrote @ 18:8:21, Wed Feb 10, 2010
Works well on the OS's for which it was designed. Since user privileges are more complicated on Vista and Windows 7, there are other APIs you must use to determine your access level. I will note that the strategy of starting a process with the "runas" verb seems to work equally well on XP as on Vista, if you determine that the user does not have admin access using the methods in this source code. If you don't need to support Windows 2000 or earlier, determining the aceess level of an XP user is really just a matter of calling IsUserAnAdmin in shell32.dll.
Copyright ©2004-2009 O. Patrick Barnes. All rights reserved.