I wrote a VB application that runs fine on one server. When I transfered it to another server I keep on getting the error: run-time error '438': Object doesn't support this property or method
The error is regarding the line: wshShell.CurrentDirectory = "T:\cs.biu.ac.il\scripts"
Please see the code below and tell me what you think:
Public Sub FindUser(ID As String)
Dim wshShell
Set wshShell = CreateObject("WScript.Shel
l")
'map network drive
Dim Connect
Set Connect = CreateObject("WScript.Netw
ork")
Connect.MapNetworkDrive "T:", "\\star\SYSVOL"
wshShell.CurrentDirectory = "T:\cs.biu.ac.il\scripts"
'create random file name
Dim fName As String
Dim objFSO1
Set objFSO1 = CreateObject("Scripting.Fi
leSystemOb
ject")
fName = CreateRandomFileName()
Do While objFSO1.FileExists(fName)
fName = CreateRandomFileName()
Loop
'execute search
Dim myCommand As String
phoneNo = ID
myCommand = "cscript search.vbs LDAP://DC=ch,DC=cs,DC=biu,
DC=ac,DC=i
l /C:telephoneNumber=" & phoneNo & " /S:subtree"
'wshShell.Run "cmd.exe /C " & myCommand & " > temp.txt"
wshShell.Run "cmd.exe /C " & myCommand & " > " & fName
'delete drive mapping
wshShell.CurrentDirectory = "C:\"
MsgBox "stam - doesn't create file without this printing - ask pinchas"
Connect.RemoveNetworkDrive
"T:"
'parsing output file
wshShell.CurrentDirectory = "\\star\SYSVOL\cs.biu.ac.i
l\scripts"
Dim objFSO, objTextFile
Dim strLinetoParse, begining, arrToken, num, strDN As String
Set objFSO = CreateObject("Scripting.Fi
leSystemOb
ject")
Set objTextFile = objFSO.OpenTextFile(fName,
1)
Do While objTextFile.AtEndOfStream <> True
strLinetoParse = objTextFile.ReadLine
begining = Mid(strLinetoParse, 1, 7)
'catches only first instance. If all instances are required remove exit do
If begining = "ADsPath" Then
arrToken = Split(strLinetoParse, " ")
num = arrToken(1)
strDN = arrToken(3)
'MsgBox strDN
Exit Do
End If
Loop
'MsgBox "Number of results is: " & num
objTextFile.Close
objFSO.DeleteFile (fName)
Set wshShell = Nothing
Set Connect = Nothing
path = strDN
End Sub
Thanks.