'## Example
If IsAdmin() Then
MsgBox "User is in the local Administrators Group"
End If
If Not IsAdmin() Then
MsgBox "User is NOT in the local Administrators Group"
End If
'## Helper Functions
Function IsAdmin()' As Boolean
Dim oG,oU
ExecuteGlobal "If IsEmpty(bIsAdmin) Then Dim bIsAdmin"
If IsEmpty(bIsAdmin) Then
bIsAdmin = False
Set oG = GetObject("WinNT://./Administrators")
For Each oU in oG.Members
If oU.Name = WshNetwork.UserName Then
bIsAdmin = true
End If
Next
End If
IsAdmin = bIsAdmin
End Function
Function WshNetwork()' As Wscript.Network
ExecuteGlobal "If IsEmpty(oWshNetwork) Then Dim oWshNetwork"
If Not IsObject(oWshNetwork) Then
Set oWshNetwork = CreateObject("Wscript.Network")
End If
Set WshNetwork = oWshNetwork
End Function
If IsAdmin() Then
MsgBox "User is in the local Administrators Group"
End If
If Not IsAdmin() Then
MsgBox "User is NOT in the local Administrators Group"
End If
'## Helper Functions
Function IsAdmin()' As Boolean
Dim oG,oU
ExecuteGlobal "If IsEmpty(bIsAdmin) Then Dim bIsAdmin"
If IsEmpty(bIsAdmin) Then
bIsAdmin = False
Set oG = GetObject("WinNT://./Administrators")
For Each oU in oG.Members
If oU.Name = WshNetwork.UserName Then
bIsAdmin = true
End If
Next
End If
IsAdmin = bIsAdmin
End Function
Function WshNetwork()' As Wscript.Network
ExecuteGlobal "If IsEmpty(oWshNetwork) Then Dim oWshNetwork"
If Not IsObject(oWshNetwork) Then
Set oWshNetwork = CreateObject("Wscript.Network")
End If
Set WshNetwork = oWshNetwork
End Function
No comments:
Post a Comment