Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Function GetNetStats(ByVal commandArgs As String) As String
On Error GoTo ErrHandler
Dim fso As New FileSystemObject
Dim so As New WshShell
Dim io As TextStream
Dim lngReturn As Long
Dim strCommand As String
Const outFile As String = "C:\NetStats.Log"
strCommand = "%comspec% /c nbtstat " & commandArgs & " > " & Chr(34) & outFile & Chr(34)
If Dir(outFile) <> "" Then
fso.DeleteFile outFile
End If
lngReturn = so.Run(strCommand, vbHide, True)
If lngReturn = 0 Then
Set io = fso.OpenTextFile(outFile, ForReading)
GetNetStats = io.ReadAll()
End If
ExitHere:
Exit Function
ErrHandler:
Debug.Print Err, Err.Description
Resume ExitHere
End Function
Dim strResults As String
strResults = GetNetStats("-a computername")
If Len(strResults) > 0 Then
[green]'parse the results[/green]
End If
Public Function GetDomainFromIP(ByVal quadDot As String) As String
Dim strResults As String
Dim strLines() As String
strResults = GetNetStats("-a " & quadDot)
If Len(strResults) > 0 Then
[green]'Parse the results[/green]
strLines = Split(strResults, vbCrLf)
strLines = Filter(strLines, "<20>")
If UBound(strLines) > -1 Then
GetDomainFromIP = Trim(Left(strLines(0), InStr(strLines(0), "<20>") - 1))
End If
End If
End Function