I've got trouble with one of my VBS script. It took a list of computer's name in entry then fill a property with name + mac address.
Code: Select all
Function getMacAddr(tabname)
macl=""
Const OpenAsDefault = -2
Const FailIfNotExist = 0
Const ForReading = 1
tab=Split(tabname,",")
Set objShell = CreateObject("WScript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
fileTemp = objShell.ExpandEnvironmentStrings("%TEMP%")
fileTempFile = fileTemp & "\" & FSO.GetTempName
For each i in tab
objShell.Run "%comspec% /c nslookup " & i & " | find /i ""."">" & fileTempFile, 0, True
Set FTempFile2 = FSO.OpenTextFile(fileTempFile, ForReading, FailIfNotExist, OpenAsDefault)
strResults = FTempFile2.ReadAll
FTempFile2.Close
FSO.DeleteFile (fileTempFile)
strResults = Replace(strResults,vbtab, "Address:")
arrIP = Split(strResults, "Address:")
Set FTempFile2 = Nothing
If UBound(arrIP) < 2 Then
dnsresult = "Unable to get IP"
Else
arrIPTemp = Split(arrIP(2), Chr(13))
dnsresult = trim(arrIPTemp(0))
objShell.Run "%comspec% /c nbtstat -a " & dnsresult & ">" & fileTempFile, 0, True
Set FTempFile3 = FSO.OpenTextFile(fileTempFile, ForReading, FailIfNotExist, OpenAsDefault)
strResults = FTempFile3.ReadAll
FTempFile3.Close
FSO.DeleteFile (fileTempFile)
artmp=Split(strResults,"MAC Address =")
macl = macl & Mid(i,3,Len(i)-2) & " " & Replace(trim(Split(artmp(1),vbCrlf)(0)),"-","") & VbCrlf
Set FTempFile3 = Nothing
End If
Next
Session.property("MACLIST") = macl 'WScript.echo macl if outside msi
Set objShell = Nothing
Set FSO = Nothing
end functionfrrampc049 0022192E5702
frampc052 002219E8DE68
frrampc044 5C260A3F4430
But when this function is called from the msi, with same parameters ( getMacAddr("\\frrampc049,\\frampc052,\\frrampc044") ) , an error is throw an script isn't executed.
By comment / uncomment script's line i found that error comes from this line " strResults = FTempFile3.ReadAll", but i don't know why...
Someone has ever had this kind of problem ?? There's a way to show msi log ?
FOLLOW US
Get the latest news in Application Packaging