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


