Intermittent "Error 424 Object Required"

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,
I am writing a vbs logon script to map to a network drive upon login. However, I am encountering a intermittent issue. Most of the times, I am able to map to the drive successfuly. Occasionally, the script fails with a Error 424 Object required. I also
tried triggereing the script numerous times on my desptop. It seems fine. Below is the snippet of my script. Any help is deeply appreciated. Thanks.

Option Explicit<br/>
Dim objNetwork,objFSO,objSysInfo,strUserDN,objUser,strLocation,wshShell,cnt,sHost,oIP,sIP<br/>
Dim strDriveLetter,strRemotePath,pingDurMin,svcDwn<br/>
strDriveLetter = "X:"<br/>
cnt=0<br/>
pingDurMin=10
Set objNetwork = CreateObject("WScript.Network")<br/>
Set objFSO = CreateObject("Scripting.FileSystemObject")<br/>
Set wshShell = CreateObject("WScript.Shell")<br/>
Set objSysInfo = CreateObject("ADSystemInfo")
<br/>
sHost=objNetwork.ComputerName<br/>
For Each oIP in GetObject("winmgmts:").execQuery("select * from win32_pingstatus where address = " & sHost & " ")<br/>
sIP=oIP.ProtocolAddress<br/>
Next
wshShell.LogEvent 0,"[" & sHost & "," & sIP & "," & objNetwork.UserName & "] Mapping script has been started"
<br/>
If pingPass() Then<br/>
On Error Resume Next<br/>
<br/>
strUserDN = objSysInfo.UserName <br/>
Set objUser = GetObject("LDAP://" & strUserDN)<br/>
strLocation = objUser.Parent
If (objFSO.DriveExists(strDriveLetter) = False) Then<br/>
If InStr(strLocation, "OU=A1,OU=B,OU=C,OU=D") Then<br/>
mapDrive<br/>
ElseIf InStr(strLocation, "OU=A2,OU=B,OU=C,OU=D") Then<br/>
mapDrive <br/>
End If<br/>
Else<br/>
Do Nothing<br/>
End If
errCheck Err.Number, Err.Description
Else<br/>
wshShell.LogEvent 1,"[" & sHost & "," & sIP & "," & objNetwork.UserName & "] Script has been terminated.
<br/>
End If
WScript.Quit<br/>

Function pingPass<br/>
Dim strGateway, objPing<br/>
pingPass=False<br/>
strGateway = "1.2.3.4"
svcDwn=DateAdd("n",pingDurMin,Now())<br/>
Do<br/>
Set objPing = GetObject("winmgmts:").InstancesOf("Win32_PingStatus" & " WHERE Address=" & strGateway & " AND statusCode=0")<br/>
If objPing.Count = 1 Then<br/>
pingPass=True<br/>
Exit Function <br/>
End If<br/>
cnt = cnt + 1<br/>
If cnt = 10 Then <br/>
WScript.Sleep 60000<br/>
cnt = 0<br/>
End If<br/>
Loop until Now > svcDwn<br/>
<br/>
End Function



View the full article
 
Back
Top