I used the below script in my group policy for staff which contains all our staff
and someone tried to log on and received an error. It seemed to work fine for my self when i tested it.
Attached is the error msg.
Can anyone tell me what i've done wrong please..
Thanks
Dim objFSO
Set objFSO = CreateObject("Scripting.Fi
leSystemOb
ject")
Dim objNetwork
Set objNetwork = CreateObject("WScript.Netw
ork")
Dim objWinntUser
Set objWinntUser = GetObject("WinNT://" & objNetwork.UserDomain & "/" & objNetwork.UserName & ",user")
Dim strGroupToCheck, strGroupShare, strDrive, strShare
'POP UP MESSAGE BOX FOR NEOS SCRIPT
dim naptime, objDOS
naptime = 2
set objDOS = CreateObject ("WScript.Shell")
objDOS.Popup "Running the Neos Script" , naptime, "Neos-IT" , 64
' Specity the group name, a colon symbol, and the network share
' in this case, the drive letter is taken as the first letter of the group name
arrGroupShares = Array( _
"Sales;S;\\Hera\Sales", _
"Technical;T;\\Hera\Techni
cal" , _
"Finance;U;\\Hera\Clients"
, _
"All Staff;N;\\Hera\Templates" _
)
For Each strGroupShare In arrGroupShares
strGroupToCheck = Split(strGroupShare, ";")(0)
strDrive = Split(strGroupShare, ";")(1)
If Right(strDrive, 1) <> ":" Then strDrive = strDrive & ":"
strShare = Split(strGroupShare, ";")(2)
If IsMemberOfGroup(objNetwork
.UserDomai
n, objWinntUser, strGroupToCheck) = True Then
'MsgBox "You are a member of " & strGroupToCheck
If objFSO.DriveExists(strDriv
e) = True Then objNetwork.RemoveNetworkDr
ive strDrive, True, True
objNetwork.MapNetworkDrive
strDrive, strShare, True
ElseIf IsMemberOfGroup(objNetwork
.UserDomai
n, objWinntUser, strGroupToCheck) = False Then
'MsgBox "You are NOT a member of " & strGroupToCheck
ElseIf IsMemberOfGroup(objNetwork
.UserDomai
n, objWinntUser, strGroupToCheck) = "Error" Then
'MsgBox "There was no group found called " & strGroupToCheck
End If
Next
Function IsMemberOfGroup(strUserDom
ain, objUser, strGroup) 'the user is a member of a specified group
IsMemberOfGroup = False
Dim objGroup
On Error Resume Next
Set objGroup = GetObject("WinNT://" & strUserDomain & "/" & strGroup & ",group")
If Err.Number Then
IsMemberOfGroup = "Error"
Else
IsMemberOfGroup = objGroup.IsMember(objUser.
ADsPath)
'MsgBox objUser.ADsPath
End If
End Function