
Error Querying ADSI via VBScript: "The Network Path Was Not Found"
I'm trying to determine how many licences of a particular software package
our users are using...
I'm doing this by checking if a particular file exist on their machines by
querying via ADSI in VBScript. The code is at the end of this msg...
I started to make some real progress, but after adding a few bits of code to
check a few things out (nothing significant) I get an error:
"PdfSpy2.vbs(44, 3) (null): The network path was not found.".
If I comment out the code concerned (see label *A*), it works... However, if
I add in the code at label *B*, I get the same error at that line later
on... The code is valid as far as I am concerned; I think that the program
is getting confused/overloaded or such-like...
Any ideas?
Thanks
CJM
Option Explicit
Dim oDomain, oPC
Dim S, M
Dim sPath
Dim oFSO, oFile, oLog
Dim sOS, x
Function Lpad(S,N)
If IsNumeric(N) Then
Lpad = S & Space(N-Len(S))
Else
Lpad = S
End if
End Function
Function Rpad(S,N)
If IsNumeric(N) Then
Rpad = Space(N-Len(S)) & S
Else
Rpad = S
End if
End Function
Function FormatKilo(N)
FormatKilo = FormatNumber((N/(1024)),0)
End Function
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oDomain = GetObject("WinNT://HEXADEX")
Set oLog = oFSO.CreateTextFile("PDFLog.txt",true)
oDomain.Filter = Array("Computer")
x=0
Wscript.Echo "Starting...."
Wscript.Echo
For Each oPC In oDomain
x=x+1
S = oPC.Name
If Right(oPC.OperatingSystemVersion,4) = "v5.0" Then *A*
sOS="winnt\"
Else
sOS="windows\"
End if
sPath = "\\" & oPC.Name & "\C$\" & sOS
If oFSO.FolderExists(sPath) Then
WScript.Echo x & ": " & Lpad(S,18) & " - no prog files"
Else
sPath = "\\" & oPC.Name & "\C$\" & sOS &
"system32\spool\drivers\w32x86\3\pscript5.dll"
If oFSO.FileExists(sPath) Then
M = ""
M = M & Lpad(S,18) & Lpad(oFSO.GetFileVersion(sPath),12)
'M = M & oPC.OperatingSystem & " v" & oPC.OperatingSystemVersion *B*
oLog.WriteLine M
Wscript.Echo x & ": " & M
Else
WScript.Echo x & ": " & Lpad(S,18) & " - n/a"
End If
End If
If x=5 then Exit For
Next
oLog.close
MsgBox ("PDFSpy Completed")