Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Login Script Causing Software to Install
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


Report this thread to moderator Post Follow-up to this message
Old Post
David Nunn
06-09-05 08:55 AM


Re: Login Script Causing Software to Install
Hi,

The accounting software installs? Hard to fathom. I did a quick search and
only found your post as relevant. Seems like it has to be a policy.

Assuming it is repeatable, and you can do some testing, I would suggest
setting up a test account (not admin) in a test OU and assign a test version
of the script as the logon script. In the test version perhaps you can add
msgbox commands and identify which line in the main body of the script
causes the problem. Otherwise, I'm stumped. Perhaps (in part):

Set objNetwork = CreateObject("Wscript.Network")
MsgBox("Step 1")
Set objFSO = CreateObject("Scripting.FileSystemObject")
MsgBox("Step 2")
Set objSysInfo = CreateObject("ADSystemInfo")
MsgBox("Step 3")
strUserDN = objSysInfo.userName
MsgBox("Step 4")

You might have to wait a moment on each msgbox to see if the install starts.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab web site - http://www.rlmueller.net
--
"David Nunn" <gimmeinfo@onewordnospaces.com> wrote in message
 news:0t9fa1p0f93jlob2rrdd47esfi1qco4m0i@
4ax.com...
> 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
>



Report this thread to moderator Post Follow-up to this message
Old Post
Richard Mueller [MVP]
06-09-05 08:55 PM


Re: Login Script Causing Software to Install
Cheers, Richard. I'll have a go at that over the wend.

I'm sure you recognize the script - I got it from your site.

On Thu, 9 Jun 2005 07:30:25 -0500, "Richard Mueller [MVP]"
<rlmueller-NOSPAM@ameritech.NOSPAM.net> wrote:

>Hi,
>
>The accounting software installs? Hard to fathom. I did a quick search and
>only found your post as relevant. Seems like it has to be a policy.
>
>Assuming it is repeatable, and you can do some testing, I would suggest
>setting up a test account (not admin) in a test OU and assign a test versio
n
>of the script as the logon script. In the test version perhaps you can add
>msgbox commands and identify which line in the main body of the script
>causes the problem. Otherwise, I'm stumped. Perhaps (in part):
>
>Set objNetwork = CreateObject("Wscript.Network")
>MsgBox("Step 1")
>Set objFSO = CreateObject("Scripting.FileSystemObject")
>MsgBox("Step 2")
>Set objSysInfo = CreateObject("ADSystemInfo")
>MsgBox("Step 3")
>strUserDN = objSysInfo.userName
>MsgBox("Step 4")
>
>You might have to wait a moment on each msgbox to see if the install starts
.
>
>--
>Richard
>Microsoft MVP Scripting and ADSI
>Hilltop Lab web site - http://www.rlmueller.net


Report this thread to moderator Post Follow-up to this message
Old Post
David Nunn
06-10-05 08:55 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

WSH archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:19 AM.

 

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.