Hi. I have a login script (login.vbs, below) that I grabbed from the
net. It works fine on the Terminal Server of one of my clients, but at
another, when Terminal Server users login, MYOB attempts to install.
The users don't have the appropriate permissions to install software,
so it fails pretty quickly, but Administrator group users have to
cancel the install. If I remove the login script from the GPO, and
then login, there is no problem, so it is definitely something to do
with the script.

My error logs show that the MYOB install is looking for an L drive,
but there is no L drive mentioned in the script, and no users have an
L drive mapped.

Any ideas?

Cheers, David Nunn.

' login.vbs
Option Explicit

Dim objNetwork, objSysInfo, strUserDN
Dim objGroupList, objUser, objFSO
Dim strComputerDN, objComputer

Set objNetwork = CreateObject("Wscript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objSysInfo = CreateObject("ADSystemInfo")
strUserDN = objSysInfo.userName
strComputerDN = objSysInfo.computerName

' Bind to the user and computer objects with the LDAP provider.
Set objUser = GetObject("LDAP://" & strUserDN)
Set objComputer = GetObject("LDAP://" & strComputerDN)

' Map a network drive if the user is a member of the group.
' Alert the user if the drive cannot be mapped.
If IsMember(objUser, "GGService") Then
If Not MapDrive("R:", "\\Melterm1\Service") Then
MsgBox "Unable to Map R: to Service"
End If
End If


' Clean up.
Set objNetwork = Nothing
Set objFSO = Nothing
Set objSysInfo = Nothing
Set objGroupList = Nothing
Set objUser = Nothing
Set objComputer = Nothing

Function IsMember(objADObject, strGroup)
' Function to test for group membership.
' objGroupList is a dictionary object with global scope.

If IsEmpty(objGroupList) Then
Set objGroupList = CreateObject("Scripting.Dictionary")
End If
If Not objGroupList.Exists(objADObject.sAMAccountName & "\") Then
Call LoadGroups(objADObject, objADObject)
objGroupList(objADObject.sAMAccountName & "\") = True
End If
IsMember = objGroupList.Exists(objADObject.sAMAccountName & "\" _
& strGroup)
End Function

Sub LoadGroups(objPriObject, objADSubObject)
' Recursive subroutine to populate dictionary object objGroupList.

Dim colstrGroups, objGroup, j

objGroupList.CompareMode = vbTextCompare
colstrGroups = objADSubObject.memberOf
If IsEmpty(colstrGroups) Then
Exit Sub
End If
If TypeName(colstrGroups) = "String" Then
Set objGroup = GetObject("LDAP://" & colstrGroups)
If Not objGroupList.Exists(objPriObject.sAMAccountName & "\" _
& objGroup.sAMAccountName) Then
objGroupList(objPriObject.sAMAccountName & "\" _
& objGroup.sAMAccountName) = True
Call LoadGroups(objPriObject, objGroup)
End If
Set objGroup = Nothing
Exit Sub
End If
For j = 0 To UBound(colstrGroups)
Set objGroup = GetObject("LDAP://" & colstrGroups(j))
If Not objGroupList.Exists(objPriObject.sAMAccountName & "\" _
& objGroup.sAMAccountName) Then
objGroupList(objPriObject.sAMAccountName & "\" _
& objGroup.sAMAccountName) = True
Call LoadGroups(objPriObject, objGroup)
End If
Next
Set objGroup = Nothing
End Sub

Function MapDrive(strDrive, strShare)
' Function to map network share to a drive letter.
' If the drive letter specified is already in use, the function
' attempts to remove the network connection.
' objFSO is the File System Object, with global scope.
' objNetwork is the Network object, with global scope.
' Returns True if drive mapped, False otherwise.

Dim objDrive

On Error Resume Next
If objFSO.DriveExists(strDrive) Then
Set objDrive = objFSO.GetDrive(strDrive)
If Err.Number <> 0 Then
On Error GoTo 0
MapDrive = False
Exit Function
End If
If CBool(objDrive.DriveType = 3) Then
objNetwork.RemoveNetworkDrive strDrive, True, True
Else
MapDrive = False
Exit Function
End If
Set objDrive = Nothing
End If
objNetwork.MapNetworkDrive strDrive, strShare
If Err.Number = 0 Then
MapDrive = True
Else
Err.Clear
MapDrive = False
End If
On Error GoTo 0
End Function