Windows Vista Forums

Logon Script Causing Laptops To Hang - Problems in script?
  1. #1


    Ben Guest

    Logon Script Causing Laptops To Hang - Problems in script?

    Hi,

    I'm using the following script to map drives, and perform a few
    functions when users logon to our domain. However, in the past 2 or 3
    months it seems that when a laptop is away from the domain, logon
    takes several minutes, and applications can take up to 2 minutes to
    start/open. The only way around tis is to disable the wi-fi
    connection, or pull the cable out of a LAN connection. However, when
    back in the office, on our network, start up is perfectly fine, and
    applications open in seconds.

    I've been advised that this behaviour is probably due to the logon
    script, somehow hunting for a domain controller to logon, waiting a
    number of minutes to try and find it, then failing. The only error
    messages in the event log are:

    Event Type: Error
    Event Source: UserInit
    Event Category: None
    Event ID: 1000
    Date: 02/02/2009
    Time: 12:51:30
    User: N/A
    Computer: LAPTOP1
    Description:
    Could not execute the following script \\server1.domain.com\NETLOGON
    \logon.vbs. The network location cannot be reached.

    Having watched the network traffic using Ethereal/Wireshark, I can't
    see anything else that looks obviously wrong.

    Could someone see if there is something in the logon script that is
    wrong? Someone suggested adding a section that exits if it can't find
    the logon server. However, if the event log is saying it can't find
    the logon script to run, I can't see how this would help!?

    Any help or suggests would be much appreciated!

    Ben

    logon.vbs
    '*******************************************

    On Error Resume Next

    '*******************************************
    'Initialize common scripting objects
    '*******************************************
    Set objNetwork = CreateObject("WScript.Network")
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set oShell = CreateObject("Wscript.Shell")
    Set objPrinter = CreateObject("WScript.Network")
    Set oSF = oShell.SpecialFolders

    '*******************************************
    ' Define Variables and ConstantsobjUser
    '*******************************************
    Dim objNetwork, objFSO, objUser, objFlrGrp

    strUserName = objNetwork.userName
    strSvrName = "server1.domain.com"
    strPtr1Name = "ptr01"
    strPtr2Name = "ptr02"
    strPtr3Name = "ptr03"
    strPtr1Path = "\\" & strSvrName & "\" & strPtr1Name
    strPtr2Path = "\\" & strSvrName & "\" & strPtr2Name
    strPtr3Path = "\\" & strSvrName & "\" & strPtr3Name
    strGrpDrv = "G:"
    strCnsltsDrv = "J:"
    strAppsDrv = "K:"
    strLibrDrv = "L:"
    strMarketDrv = "M:"
    strInvoiceDrv = "N:"
    strDictrDrv = "O:"
    strAcntsDrv = "P:"
    strHrDrv = "R:"
    strSaleDrv = "S:"
    strTrainDrv = "T:"
    strAcntsShr = "\accounts"
    strInvoiceShr = "\InvoiceProc"
    strAppsShr = "\apps"
    strCnsltsShr = "\consultants"
    strDictrShr = "\directors"
    strGrpShr = "\group"
    strLibrShr = "\library"
    strHrShr = "\hr"
    strSaleShr = "\sales"
    strMarketShr = "\marketing"
    strTrainShr = "\training"

    '*******************************************
    'Disconnects Drives This assures everyone has the same drive mappings.
    '*******************************************
    Dim objDrive
    objDrives = array
    ("G:","J:","K:","L:","M:","N:","P:","P:","R:","S:","T:")
    For Each oDrive in objDrives
    IF objFSO.DriveExists(oDrive) = True Then
    objNetwork.RemoveNetworkDrive oDrive, true
    End IF
    Next

    '*******************************************
    'Audit's Laptop Software Once Every Seven Days
    '*******************************************
    oPath = "\\server1.domain.com\Audits\"
    oComputer = oPath & objNetwork.ComputerName & "-audit.txt"
    If objFSO.FileExists(oComputer) = True Then
    Set ofile = objFSO.GetFile(oComputer)'get the file
    fDate = ofile.DateLastModified 'file date
    tdate = Now 'todays date
    dDate = DateDiff("d", fdate, tdate) 'calculate the number of days
    difference
    if dDate > 7 then
    Call Audit
    else
    Set ofile = Nothing
    end if
    else
    Call Audit
    End if
    Function Audit
    strCommand="%comspec% /c" & oPath & "psinfo.exe -s * >" & oPath &
    "%ComputerName%-audit.txt"
    intWindowStyle=0
    oShell.Run strCommand, intWindowStyle
    end Function

    '*******************************************
    ' Map global Drives & Drives based on Group Membership
    '*******************************************
    'Group drive
    strPath = "\\" & strSvrName & strGrpShr
    objNetwork.MapNetworkDrive strGrpDrv, strPath
    'Training
    strPath = "\\" & strSvrName & strTrainShr
    objNetwork.MapNetworkDrive strTrainDrv, strPath
    'Library
    strPath = "\\" & strSvrName & strLibrShr
    objNetwork.MapNetworkDrive strLibrDrv, strPath



    if IsMember("Accountants") then
    strPath = "\\" & strSvrName & strAcntsShr
    objNetwork.MapNetworkDrive strAcntsDrv, strPath
    end if
    if IsMember("Consultants") then
    strPath = "\\" & strSvrName & strCnsltsShr
    objNetwork.MapNetworkDrive strCnsltsDrv, strPath
    end if
    if IsMember("Admins") then
    strPath = "\\" & strSvrName & strItShr
    objNetwork.MapNetworkDrive strItDrv, strPath
    end if
    if IsMember("Directors") then
    strPath = "\\" & strSvrName & strDictrShr
    objNetwork.MapNetworkDrive strDictrDrv, strPath
    end if
    if IsMember("HumanResources") then
    strPath = "\\" & strSvrName & strHrShr
    objNetwork.MapNetworkDrive strHrDrv, strPath
    end if
    if IsMember("SalesGroup") then
    strPath = "\\" & strSvrName & strSaleShr
    objNetwork.MapNetworkDrive strSaleDrv, strPath
    strPath = "\\" & strSvrName & strMarketShr
    objNetwork.MapNetworkDrive strMarketDrv, strPath
    strPath = "\\" & strSvrName & strInvoiceShr
    objNetwork.MapNetworkDrive strInvoiceDrv, strPath
    end if

    '*******************************************
    ' This section sets default printers depending on location
    '*******************************************
    if IsMember("PTR01 Users") then
    objNetwork.SetDefaultPrinter strPtr1Path
    elseif IsMember("PTR02 Users") then
    objNetwork.SetDefaultPrinter strPtr2Path
    elseif IsMember("PTR03 Users") then
    objNetwork.SetDefaultPrinter strPtr3Path
    end if

    '*******************************************
    ' This Function Gets Domain Group Membership
    '*******************************************
    Function IsMember(strGroup)
    Dim objNetwork, objSysInfo, strUserDN, objUser

    Set objSysInfo = CreateObject("ADSystemInfo")
    strUserDN = objSysInfo.userName
    Set objUser = GetObject("LDAP://" & strUserDN)

    Dim objGroup
    If IsEmpty(objGroupList) Then
    Set objGroupList = CreateObject("Scripting.Dictionary")
    objGroupList.CompareMode = vbTextCompare
    For Each objGroup In objUser.Groups
    objGroupList(objGroup.sAMAccountName) = True
    Next
    End If
    IsMember = objGroupList.Exists(strGroup)
    End Function

    Set objGroupList = Nothing

    '*******************************************
    '*Create Outlook signature if it doesn't exist
    '*******************************************
    oSigPath = "C:\Documents and Settings\" & strUserName & "\Application
    Data\Microsoft\Signatures\AD Signature.rtf"
    If objFSO.FileExists(oSigPath) = True Then
    else
    oShell.Run "\\server1.domain.com\NETLOGON\ADSignatureSetup.vbs"
    End if

    Set objNetwork = Nothing
    Set objFSO = Nothing
    Set oShell = Nothing
    Set objPrinter = Nothing
    Set objUser = Nothing
    Set objSysInfo = Nothing
    Set colProcess = Nothing
    Set objWMIService = Nothing

    ' Exit Script
    WSCript.Quit

      My System SpecsSystem Spec

  2. #2


    Pegasus \(MVP\) Guest

    Re: Logon Script Causing Laptops To Hang - Problems in script?


    "Ben" <bjblackmore@xxxxxx> wrote in message
    news:8c7e5928-b141-4abb-b722-e32157efe408@xxxxxx

    > Hi,
    >
    > I'm using the following script to map drives, and perform a few
    > functions when users logon to our domain. However, in the past 2 or 3
    > months it seems that when a laptop is away from the domain, logon
    > takes several minutes, and applications can take up to 2 minutes to
    > start/open. The only way around tis is to disable the wi-fi
    > connection, or pull the cable out of a LAN connection. However, when
    > back in the office, on our network, start up is perfectly fine, and
    > applications open in seconds.
    >
    > I've been advised that this behaviour is probably due to the logon
    > script, somehow hunting for a domain controller to logon, waiting a
    > number of minutes to try and find it, then failing. The only error
    > messages in the event log are:
    >
    > Event Type: Error
    > Event Source: UserInit
    > Event Category: None
    > Event ID: 1000
    > Date: 02/02/2009
    > Time: 12:51:30
    > User: N/A
    > Computer: LAPTOP1
    > Description:
    > Could not execute the following script \\server1.domain.com\NETLOGON
    > \logon.vbs. The network location cannot be reached.
    >
    > Having watched the network traffic using Ethereal/Wireshark, I can't
    > see anything else that looks obviously wrong.
    >
    > Could someone see if there is something in the logon script that is
    > wrong? Someone suggested adding a section that exits if it can't find
    > the logon server. However, if the event log is saying it can't find
    > the logon script to run, I can't see how this would help!?
    >
    > Any help or suggests would be much appreciated!
    >
    > Ben
    I would insert an instruction right at the beginning of the script to exit
    if the domain controller is inaccessible.



      My System SpecsSystem Spec

  3. #3


    Ben Guest

    Re: Logon Script Causing Laptops To Hang - Problems in script?

    On 2 Feb, 17:01, "Pegasus \(MVP\)" <I....@xxxxxx> wrote:

    > "Ben" <bjblackm...@xxxxxx> wrote in message
    >
    > news:8c7e5928-b141-4abb-b722-e32157efe408@xxxxxx
    >
    >
    >
    >
    >

    > > Hi,
    >

    > > I'm using the following script to map drives, and perform a few
    > > functions when users logon to our domain. However, in the past 2 or 3
    > > months it seems that when a laptop is away from the domain, logon
    > > takes several minutes, and applications can take up to 2 minutes to
    > > start/open. The only way around tis is to disable the wi-fi
    > > connection, or pull the cable out of a LAN connection. However, when
    > > back in the office, on our network, start up is perfectly fine, and
    > > applications open in seconds.
    >

    > > I've been advised that this behaviour is probably due to the logon
    > > script, somehow hunting for a domain controller to logon, waiting a
    > > number of minutes to try and find it, then failing. The only error
    > > messages in the event log are:
    >

    > > Event Type: Error
    > > Event Source: UserInit
    > > Event Category: None
    > > Event ID: 1000
    > > Date: 02/02/2009
    > > Time: 12:51:30
    > > User: N/A
    > > Computer: LAPTOP1
    > > Description:
    > > Could not execute the following script \\server1.domain.com\NETLOGON
    > > \logon.vbs. The network location cannot be reached.
    >

    > > Having watched the network traffic using Ethereal/Wireshark, I can't
    > > see anything else that looks obviously wrong.
    >

    > > Could someone see if there is something in the logon script that is
    > > wrong? Someone suggested adding a section that exits if it can't find
    > > the logon server. However, if the event log is saying it can't find
    > > the logon script to run, I can't see how this would help!?
    >

    > > Any help or suggests would be much appreciated!
    >

    > > Ben
    >
    > I would insert an instruction right at the beginning of the script to exit
    > if the domain controller is inaccessible.- Hide quoted text -
    >
    > - Show quoted text -
    Thanks for the reply.

    Would the following code work?

    Set oRootDSE = GetObject("LDAP://RootDSE")
    strDNC = oRootDSE.get("DefaultNamingContext")
    If (Err.Number <> 0) Then
    WScript.Quit
    End If

      My System SpecsSystem Spec

  4. #4


    Richard Mueller [MVP] Guest

    Re: Logon Script Causing Laptops To Hang - Problems in script?


    "Ben" <bjblackmore@xxxxxx> wrote in message
    news:935b1e32-784a-4474-8605-da86d34eaa9f@xxxxxx

    > On 2 Feb, 17:01, "Pegasus \(MVP\)" <I....@xxxxxx> wrote:

    >> "Ben" <bjblackm...@xxxxxx> wrote in message
    >>
    >> news:8c7e5928-b141-4abb-b722-e32157efe408@xxxxxx
    >>
    >>
    >>
    >>
    >>

    >> > Hi,
    >>

    >> > I'm using the following script to map drives, and perform a few
    >> > functions when users logon to our domain. However, in the past 2 or 3
    >> > months it seems that when a laptop is away from the domain, logon
    >> > takes several minutes, and applications can take up to 2 minutes to
    >> > start/open. The only way around tis is to disable the wi-fi
    >> > connection, or pull the cable out of a LAN connection. However, when
    >> > back in the office, on our network, start up is perfectly fine, and
    >> > applications open in seconds.
    >>

    >> > I've been advised that this behaviour is probably due to the logon
    >> > script, somehow hunting for a domain controller to logon, waiting a
    >> > number of minutes to try and find it, then failing. The only error
    >> > messages in the event log are:
    >>

    >> > Event Type: Error
    >> > Event Source: UserInit
    >> > Event Category: None
    >> > Event ID: 1000
    >> > Date: 02/02/2009
    >> > Time: 12:51:30
    >> > User: N/A
    >> > Computer: LAPTOP1
    >> > Description:
    >> > Could not execute the following script \\server1.domain.com\NETLOGON
    >> > \logon.vbs. The network location cannot be reached.
    >>

    >> > Having watched the network traffic using Ethereal/Wireshark, I can't
    >> > see anything else that looks obviously wrong.
    >>

    >> > Could someone see if there is something in the logon script that is
    >> > wrong? Someone suggested adding a section that exits if it can't find
    >> > the logon server. However, if the event log is saying it can't find
    >> > the logon script to run, I can't see how this would help!?
    >>

    >> > Any help or suggests would be much appreciated!
    >>

    >> > Ben
    >>
    >> I would insert an instruction right at the beginning of the script to
    >> exit
    >> if the domain controller is inaccessible.- Hide quoted text -
    >>
    >> - Show quoted text -
    >
    > Thanks for the reply.
    >
    > Would the following code work?
    >
    > Set oRootDSE = GetObject("LDAP://RootDSE")
    > strDNC = oRootDSE.get("DefaultNamingContext")
    > If (Err.Number <> 0) Then
    > WScript.Quit
    > End If
    Yes. Also, I would remove "On Error Resume Next" so you get an error message
    that will provide a clue. It could be a specific computer, like Server1,
    cannot be contacted, rather than a DC. After a quick glance the only part I
    see that requires a DC is where you bind to "ADSystemInfo". You might use
    error trapping in the function IsMember method. However, the script will
    still fail if Server1 is not available.

    --
    Richard Mueller
    MVP Directory Services
    Hilltop Lab - http://www.rlmueller.net
    --



      My System SpecsSystem Spec

  5. #5


    Ben Guest

    Re: Logon Script Causing Laptops To Hang - Problems in script?

    On 2 Feb, 18:44, "Richard Mueller [MVP]" <rlmueller-
    nos...@xxxxxx> wrote:

    > "Ben" <bjblackm...@xxxxxx> wrote in message
    >
    > news:935b1e32-784a-4474-8605-da86d34eaa9f@xxxxxx
    >
    >
    >
    >
    >

    > > On 2 Feb, 17:01, "Pegasus \(MVP\)" <I....@xxxxxx> wrote:

    > >> "Ben" <bjblackm...@xxxxxx> wrote in message
    >

    > >>news:8c7e5928-b141-4abb-b722-e32157efe408@xxxxxx
    >

    > >> > Hi,
    >

    > >> > I'm using the following script to map drives, and perform a few
    > >> > functions when users logon to our domain. However, in the past 2 or 3
    > >> > months it seems that when a laptop is away from the domain, logon
    > >> > takes several minutes, and applications can take up to 2 minutes to
    > >> > start/open. The only way around tis is to disable the wi-fi
    > >> > connection, or pull the cable out of a LAN connection. However, when
    > >> > back in the office, on our network, start up is perfectly fine, and
    > >> > applications open in seconds.
    >

    > >> > I've been advised that this behaviour is probably due to the logon
    > >> > script, somehow hunting for a domain controller to logon, waiting a
    > >> > number of minutes to try and find it, then failing. The only error
    > >> > messages in the event log are:
    >

    > >> > Event Type: Error
    > >> > Event Source: UserInit
    > >> > Event Category: None
    > >> > Event ID: 1000
    > >> > Date: 02/02/2009
    > >> > Time: 12:51:30
    > >> > User: N/A
    > >> > Computer: LAPTOP1
    > >> > Description:
    > >> > Could not execute the following script \\server1.domain.com\NETLOGON
    > >> > \logon.vbs. The network location cannot be reached.
    >

    > >> > Having watched the network traffic using Ethereal/Wireshark, I can't
    > >> > see anything else that looks obviously wrong.
    >

    > >> > Could someone see if there is something in the logon script that is
    > >> > wrong? Someone suggested adding a section that exits if it can't find
    > >> > the logon server. However, if the event log is saying it can't find
    > >> > the logon script to run, I can't see how this would help!?
    >

    > >> > Any help or suggests would be much appreciated!
    >

    > >> > Ben
    >

    > >> I would insert an instruction right at the beginning of the script to
    > >> exit
    > >> if the domain controller is inaccessible.- Hide quoted text -
    >

    > >> - Show quoted text -
    >

    > > Thanks for the reply.
    >

    > > Would the following code work?
    >

    > > Set oRootDSE = GetObject("LDAP://RootDSE")
    > > strDNC = oRootDSE.get("DefaultNamingContext")
    > > If (Err.Number <> 0) Then
    > > WScript.Quit
    > > End If
    >
    > Yes. Also, I would remove "On Error Resume Next" so you get an error message
    > that will provide a clue. It could be a specific computer, like Server1,
    > cannot be contacted, rather than a DC. After a quick glance the only part I
    > see that requires a DC is where you bind to "ADSystemInfo". You might use
    > error trapping in the function IsMember method. However, the script will
    > still fail if Server1 is not available.
    >
    > --
    > Richard Mueller
    > MVP Directory Services
    > Hilltop Lab -http://www.rlmueller.net
    > --- Hide quoted text -
    >
    > - Show quoted text -
    Thanks RIchard.

    One last question - I'm just wondering how all this works?

    The error in the event logs says "Could not execute the following
    script \\server1.domain.com\NETLOGON\logon.vbs. The network location
    cannot be reached." Does this mean it can't find the script to
    execute, in which case, will adding the above code make any
    difference? Or is the script cached (its a logon script in a group
    policy, so possibly), and the error means it can't find the network
    while running the script?

    Thanks again

    Ben

      My System SpecsSystem Spec

  6. #6


    Richard Mueller [MVP] Guest

    Re: Logon Script Causing Laptops To Hang - Problems in script?


    "Ben" <bjblackmore@xxxxxx> wrote in message
    news:16fe10da-8ab8-4f57-a827-e0f37e5e296d@xxxxxx

    > On 2 Feb, 18:44, "Richard Mueller [MVP]" <rlmueller-
    > nos...@xxxxxx> wrote:

    >> "Ben" <bjblackm...@xxxxxx> wrote in message
    >>
    >> news:935b1e32-784a-4474-8605-da86d34eaa9f@xxxxxx
    >>
    >>
    >>
    >>
    >>

    >> > On 2 Feb, 17:01, "Pegasus \(MVP\)" <I....@xxxxxx> wrote:
    >> >> "Ben" <bjblackm...@xxxxxx> wrote in message
    >>

    >> >>news:8c7e5928-b141-4abb-b722-e32157efe408@xxxxxx
    >>

    >> >> > Hi,
    >>

    >> >> > I'm using the following script to map drives, and perform a few
    >> >> > functions when users logon to our domain. However, in the past 2 or
    >> >> > 3
    >> >> > months it seems that when a laptop is away from the domain, logon
    >> >> > takes several minutes, and applications can take up to 2 minutes to
    >> >> > start/open. The only way around tis is to disable the wi-fi
    >> >> > connection, or pull the cable out of a LAN connection. However, when
    >> >> > back in the office, on our network, start up is perfectly fine, and
    >> >> > applications open in seconds.
    >>

    >> >> > I've been advised that this behaviour is probably due to the logon
    >> >> > script, somehow hunting for a domain controller to logon, waiting a
    >> >> > number of minutes to try and find it, then failing. The only error
    >> >> > messages in the event log are:
    >>

    >> >> > Event Type: Error
    >> >> > Event Source: UserInit
    >> >> > Event Category: None
    >> >> > Event ID: 1000
    >> >> > Date: 02/02/2009
    >> >> > Time: 12:51:30
    >> >> > User: N/A
    >> >> > Computer: LAPTOP1
    >> >> > Description:
    >> >> > Could not execute the following script \\server1.domain.com\NETLOGON
    >> >> > \logon.vbs. The network location cannot be reached.
    >>

    >> >> > Having watched the network traffic using Ethereal/Wireshark, I can't
    >> >> > see anything else that looks obviously wrong.
    >>

    >> >> > Could someone see if there is something in the logon script that is
    >> >> > wrong? Someone suggested adding a section that exits if it can't
    >> >> > find
    >> >> > the logon server. However, if the event log is saying it can't find
    >> >> > the logon script to run, I can't see how this would help!?
    >>

    >> >> > Any help or suggests would be much appreciated!
    >>

    >> >> > Ben
    >>

    >> >> I would insert an instruction right at the beginning of the script to
    >> >> exit
    >> >> if the domain controller is inaccessible.- Hide quoted text -
    >>

    >> >> - Show quoted text -
    >>

    >> > Thanks for the reply.
    >>

    >> > Would the following code work?
    >>

    >> > Set oRootDSE = GetObject("LDAP://RootDSE")
    >> > strDNC = oRootDSE.get("DefaultNamingContext")
    >> > If (Err.Number <> 0) Then
    >> > WScript.Quit
    >> > End If
    >>
    >> Yes. Also, I would remove "On Error Resume Next" so you get an error
    >> message
    >> that will provide a clue. It could be a specific computer, like Server1,
    >> cannot be contacted, rather than a DC. After a quick glance the only part
    >> I
    >> see that requires a DC is where you bind to "ADSystemInfo". You might use
    >> error trapping in the function IsMember method. However, the script will
    >> still fail if Server1 is not available.
    >>
    >> --
    >> Richard Mueller
    >> MVP Directory Services
    >> Hilltop Lab -http://www.rlmueller.net
    >> --- Hide quoted text -
    >>
    >> - Show quoted text -
    >
    > Thanks RIchard.
    >
    > One last question - I'm just wondering how all this works?
    >
    > The error in the event logs says "Could not execute the following
    > script \\server1.domain.com\NETLOGON\logon.vbs. The network location
    > cannot be reached." Does this mean it can't find the script to
    > execute, in which case, will adding the above code make any
    > difference? Or is the script cached (its a logon script in a group
    > policy, so possibly), and the error means it can't find the network
    > while running the script?
    >
    > Thanks again
    >
    > Ben
    I think you are correct, the logon script file is not being located.

    You say the logon script is specified in a group policy, but if so that is
    the wrong location. That is the location for logon scripts specified on the
    Profile tab of ADUC. Best would be to copy the logon script file, logon.vbs,
    to the clipboard, then navigate in Group Policy, open the "Logon" setting in
    the Group Policy editor, press the "Show Files..." button, and paste the
    file in the dialog. Then you can select the file as the logon script. This
    ensure the file is in the correct location. See this link for more on
    configuring logon scripts:

    http://www.rlmueller.net/LogonScriptFAQ.htm

    --
    Richard Mueller
    MVP Directory Services
    Hilltop Lab - http://www.rlmueller.net
    --



      My System SpecsSystem Spec

Logon Script Causing Laptops To Hang - Problems in script? problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Logon script xanti VB Script 3 18 Oct 2009
Logon script George PowerShell 1 03 Apr 2009
Logon Script Martín Companucci VB Script 4 16 Oct 2008
CDO script causes Exchange Server to hang Trey Shaffer VB Script 1 25 Jun 2008
Logon Script randyh@newsgroups.nospam Vista General 1 29 Nov 2006