Hjælp med et nslookup script.
Hej.Jeg sidder og arbejder på et nslookup script i VBS. Jeg har allerede arbejdet lidt på scriptet, men jeg har et helt simpelt problem. Når man skal fortage selve lookup'et, så benytter scriptet sig af en fil der hedder "sl.txt".
Jeg vil meget gerne have at scriptet benytter sig af en Inputbox i stedet, men jeg kan ikke få det til at virke. Den brokker sig bare over noget object.
Her er selve koden:
----------------------
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set SrvList = objFSO.OpenTextFile("sl.txt")
Do Until SrvList.AtEndOfStream
strComputer = lcase(srvlist.readline)
if checkserverResponse(strComputer) then
srvIP = checkServerIP(strComputer)
wscript.echo "Hostname: "& strComputer & vbNewLine & "IP: "& srvIP &vbNewLine & vbNewLine& "Do you want to remote?"
else
wscript.echo strComputer & " is unfortunately down."
end if
Loop
Function checkServerIP(serverName)
strTarget = serverName
Set objShell = CreateObject("WScript.Shell")
Set objExec = objShell.Exec("ping -n 1 " & strTarget)
blank = LCase(objExec.StdOut.ReadLine)
strPingResults = LCase(objExec.StdOut.ReadLine)
split1 = split(strPingResults)
tempIP = split1(2)
checkServerIP = mid(tempIP,2,(len(tempIP)-2))
End Function
Function checkServerName(serverIP)
strTarget = serverIP
Set objShell = CreateObject("WScript.Shell")
Set objExec = objShell.Exec("ping -n 1 -a " & strTarget)
blank = LCase(objExec.StdOut.ReadLine)
strPingResults = LCase(objExec.StdOut.ReadLine)
split2 = split(strPingResults)
tempHostName = split2(1)
checkServerName = tempHostName
End Function
Function checkServerResponse(serverName)
strTarget = serverName
Set objShell = CreateObject("WScript.Shell")
Set objExec = objShell.Exec("ping -n 1 -w 1000 " & strTarget)
strPingResults = LCase(objExec.StdOut.ReadAll)
If InStr(strPingResults, "reply from") Then
checkServerResponse = true
Else
checkServerResponse = false
End If
End Function