Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- outFilePath = "C:\Users\stud\Desktop\labip.txt"
- Set objOutputFile = objFSO.CreateTextFile(outFilePath, True)
- Set AdaptersConfigs = GetObject("WinMgmTs:").InstancesOf("Win32_NetworkAdapterConfiguration")
- For Each AdapterConfig in AdaptersConfigs
- If AdapterConfig.IPEnabled then
- strIP = AdapterConfig.IPAddress(0)
- strDefGate = AdapterConfig.DefaultIPGateway(0)
- strSubMask = AdapterConfig.IPSubnet(0)
- strMAC = AdapterConfig.MACAddress
- objOutputFile.Write "IP Address: " & strIP & vbCrLf
- objOutputFile.Write "Subnet mask: " & strSubMask & vbCrLf
- objOutputFile.Write "Default Gateway: " & strDefGate & vbCrLf
- objOutputFile.Write "MAC: " &strMAC & vbCrLf
- strDHCP = AdapterConfig.DHCPServer
- strDNS = AdapterConfig.DNSServerSearchOrder(0)
- objOutputFile.Write "DHCP: "&strDHCP&vbCrLf
- objOutputFile.Write "DNS: "&strDNS&vbCrLf
- Set objMgmt = GetObject("WinMgmTs:{impersonationLevel=impersonate}//./root/cimv2")
- objOutputFile.Write "www.nvidia.ru: " & vbCrLf
- Set pingResults = objMgmt.ExecQuery("SELECT * FROM Win32_PingStatus WHERE Address = '" & "www.nvidia.ru" & "'")
- For Each pingResult in pingResults
- If pingResult.StatusCode = 0 Then
- objOutputFile.Write "Response time: " & pingResult.ResponseTime & " ms" & vbCrLf
- Else
- objOutputFile.Write "Server didn't respond" & vbCrLf
- End If
- Next
- Set pingResults = objMgmt.ExecQuery("SELECT * FROM Win32_PingStatus WHERE Address = '" & strDefGate & "'")
- For Each pingResult in pingResults
- If pingResult.StatusCode = 0 Then
- objOutputFile.Write "Response time (DefGate): " & pingResult.ResponseTime & " ms" & vbCrLf
- Else
- objOutputFile.Write "Server didn't respond" & vbCrLf
- End If
- Next
- 'objOutputFile.Write "Network bandwidth: "& vbCrLf
- ' Set objShell = CreateObject("WScript.Shell")
- ' Set objServExec = objShell.Exec("iperf3 -s")
- ' Set objClientExec = objShell.Exec("iperf3 -c" & strIP)
- ' Set objStdOut = objClientExec.StdOut
- ' While Not objStdOut.AtEndOfStream
- ' strLine = objStdOut.ReadLine
- ' objOutputFile.Write strLine & vbCrLf
- ' Wend
- ' objClientExec.Terminate
- ' objServExec.Terminate
- Set objShell = CreateObject("WScript.Shell")
- Set objTraceRtExec = objShell.Exec("tracert -h 3 www.nvidia.ru")
- Set objStdOut = objTraceRtExec.StdOut
- While Not objStdOut.AtEndOfStream
- strLine = objStdOut.ReadLine
- objOutputFile.Write strLine & vbCrLf
- Wend
- objTraceRtExec.Terminate
- objOutputFile.Write " All routers addresses between computer and www.nvidia.ru: " & vbCrLf
- Set objTraceRtExec = objShell.Exec("tracert www.nvidia.ru")
- Set objStdOut = objTraceRtExec.StdOut
- Set list = CreateObject("Scripting.Dictionary")
- While Not objStdOut.AtEndOfStream
- strLine = objStdOut.ReadLine
- objOutputFile.Write strLine & vbCrLf
- startLine = strLine
- isFirst = true
- isTooSlow = false
- If Left(strLine,5) <> " " Then
- If Left(strLine,1) = " " Then
- loopNumber = 0
- While loopNumber <> 6
- strLine = Ltrim(strLine)
- strLine = Rtrim(strLine)
- n = ""
- While Left(strLine,1) <> " "
- n = n & Left(strLine,1)
- strLine = Right(strLine,Len(strLine)-1)
- Wend
- If isFirst <> true Then
- If IsNumeric(n) Then
- resp_time = CInt(n)
- If resp_time > 20 Then
- isTooSlow = true
- End If
- End If
- Else
- isFirst = false
- End If
- loopNumber = loopNumber + 1
- Wend
- End If
- End If
- If isTooSlow = True Then
- list.Add startLine, startLine
- End If
- Wend
- objTraceRtExec.Terminate
- 'objOutputFile.Write "5. Network bandwidth: "& vbCrLf
- ' Set objShell = CreateObject("WScript.Shell")
- 'Set objServExec = objShell.Exec("iperf3 -s")
- 'Set objClientExec = objShell.Exec("iperf3 -c" & strIP)
- ' Set objStdOut = objClientExec.StdOut
- ' While Not objStdOut.AtEndOfStream
- ' strLine = objStdOut.ReadLine
- ' objOutputFile.Write strLine & vbCrLf
- ' Wend
- ' objClientExec.Terminate
- ' objServExec.Terminate
- Set objTraceRtExec = objShell.Exec("arp -a")
- Set objStdOut = objTraceRtExec.StdOut
- While Not objStdOut.AtEndOfStream
- strLine = objStdOut.ReadLine
- objOutputFile.Write strLine & vbCrLf
- Wend
- objTraceRtExec.Terminate
- Set objTraceRtExec = objShell.Exec("netstat -n")
- Set objStdOut = objTraceRtExec.StdOut
- While Not objStdOut.AtEndOfStream
- strLine = objStdOut.ReadLine
- objOutputFile.Write strLine & vbCrLf
- Wend
- objTraceRtExec.Terminate
- isNotMaxMTU = true
- buffSize = 1450
- While isNotMaxMTU
- Set pingResults = objMgmt.ExecQuery("SELECT * FROM Win32_PingStatus WHERE Address = 'www.nvidia.ru' and BufferSize = " & CStr(buffSize) & " and NoFragmentation = true")
- For Each pingResult in pingResults
- If pingResult.StatusCode = 0 Then
- objOutputFile.Write "Response time for " & Cstr(buffSize) & " bytes: " & pingResult.ResponseTime & " ms" & vbCrLf
- buffSize = buffSize + 1
- ElseIf pingResult.StatusCode = 11009 Then
- buffSize = buffSize - 1
- objOutputFile.Write "Max MTU of nvidia: " & CStr(buffSize) & vbCrLf
- isNotMaxMTU = false
- ElseIf buffSize > 1500 Then
- isNotMaxMTU = false
- objOutputFile.Write "Something went wrong and MTU stayed unknown" & vbCrLf
- Else
- buffSize = buffSize + 1
- End If
- Next
- Wend
- Set objTraceRtExec = objShell.Exec("notepad " & outFilePath)
- Exit For
- end if
- next
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement