Script Library
Function fAdminTest()
Search thecollinshouse script library:
Script Type: vbScript function
Description:
This function tests whether the current user is a local admin. It does this by testing if the user can access the computer via the administrative Admin$ share. Therefore this share must still be active and the computer must be connected to a network for this to work. Tested on Windows XP.
Script:

'# D.Collins - 11:56 20/10/2006
'# Tests if user has local admin rights.
'# Note:  Only works if the computer is connected to a network



UserIsAdmin = fAdminTest()

MsgBox "User Is Admin = " & UserIsAdmin

Function fAdminTest()
    Dim wshShell, fso, temp
    Set wshShell = CreateObject("WScript.Shell")
    Set fso = CreateObject("Scripting.FileSystemObject")
    If fso.FolderExists(wshShell.ExpandEnvironmentStrings("\\%COMPUTERNAME%\Admin$\System32\")) Then
        temp = True
    Else
        temp = False
    End If
    fAdminTest = temp
    Set fso = Nothing
End Function

Script Library Index | thecollinshouse Home
25141