Test for Admin Rights - Fast, Small, Efficient, Universal Script Code in VBS and CMD/BAT Print E-mail

This script code uses a fast and efficient method for determining whether the current session (process) has admin rights.  The compact code is provided in VBS (9 lines) and CMD/BAT (3 lines).  It works with XP / Server 2003 through Windows 7 / Server 2008.  It works with UAC (reports admin rights only if session / process elevated).  It uses passive methods to determine rights – in other words, it does not try to change anything on the target system.

This script is a quick and universal method – unlike the CSI-Toolkit VBScript IfUserPerms, it cannot tell you that the user COULD elevate if you prompted them, nor can it tell you any of the user’s other special permissions.  IfUserPerms, however, relies on whoami (not present on XP and 2003) and is only provided in VBS.

Download the attachment for both the .CMD/.BAT and .VBS versions of this script code.

Attachments:
Download this file (CSI_IsAdmin.zip)CSI_IsAdmin.zip[ ]2 Kb