Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Set objFSO = CreateObject("Scripting.FileSystemObject")
  2. outFilePath = "C:\Users\stud\Desktop\labip.txt"
  3. Set objOutputFile = objFSO.CreateTextFile(outFilePath, True)
  4. Set AdaptersConfigs = GetObject("WinMgmTs:").InstancesOf("Win32_NetworkAdapterConfiguration")
  5. For Each AdapterConfig in AdaptersConfigs
  6. If AdapterConfig.IPEnabled then
  7.         strIP = AdapterConfig.IPAddress(0)
  8.         strDefGate = AdapterConfig.DefaultIPGateway(0)
  9.         strSubMask = AdapterConfig.IPSubnet(0)
  10.         strMAC = AdapterConfig.MACAddress
  11.         objOutputFile.Write "IP Address:  " & strIP & vbCrLf
  12.                 objOutputFile.Write "Subnet mask:  " & strSubMask & vbCrLf
  13.         objOutputFile.Write "Default Gateway: " & strDefGate & vbCrLf      
  14.         objOutputFile.Write "MAC: " &strMAC & vbCrLf
  15.  
  16. strDHCP = AdapterConfig.DHCPServer
  17. strDNS = AdapterConfig.DNSServerSearchOrder(0)
  18. objOutputFile.Write "DHCP: "&strDHCP&vbCrLf
  19. objOutputFile.Write "DNS: "&strDNS&vbCrLf
  20.  
  21. Set objMgmt = GetObject("WinMgmTs:{impersonationLevel=impersonate}//./root/cimv2")
  22. objOutputFile.Write "www.nvidia.ru: " & vbCrLf     
  23.         Set pingResults = objMgmt.ExecQuery("SELECT * FROM Win32_PingStatus WHERE Address = '" & "www.nvidia.ru" & "'")
  24.         For Each pingResult in pingResults
  25.             If pingResult.StatusCode = 0 Then
  26.                 objOutputFile.Write "Response time: " & pingResult.ResponseTime & " ms" & vbCrLf   
  27.             Else
  28.                 objOutputFile.Write "Server didn't respond" & vbCrLf
  29.             End If
  30.         Next
  31.  
  32.  
  33. Set pingResults = objMgmt.ExecQuery("SELECT * FROM Win32_PingStatus WHERE Address = '" & strDefGate & "'")
  34.         For Each pingResult in pingResults
  35.             If pingResult.StatusCode = 0 Then
  36.                 objOutputFile.Write "Response time (DefGate): " & pingResult.ResponseTime & " ms" & vbCrLf 
  37.             Else
  38.                 objOutputFile.Write "Server didn't respond" & vbCrLf
  39.             End If
  40.         Next
  41.  
  42.  
  43.  
  44.  
  45. 'objOutputFile.Write "Network bandwidth: "& vbCrLf
  46. '       Set objShell = CreateObject("WScript.Shell")
  47. '       Set objServExec = objShell.Exec("iperf3 -s")
  48. '       Set objClientExec = objShell.Exec("iperf3 -c" & strIP)
  49. '       Set objStdOut = objClientExec.StdOut
  50. '       While Not objStdOut.AtEndOfStream
  51. '           strLine = objStdOut.ReadLine
  52. '           objOutputFile.Write strLine & vbCrLf
  53. '       Wend
  54. '       objClientExec.Terminate
  55. '       objServExec.Terminate
  56.        
  57.  
  58.  
  59.  
  60.  
  61. Set objShell = CreateObject("WScript.Shell")
  62. Set objTraceRtExec = objShell.Exec("tracert -h 3 www.nvidia.ru")
  63.         Set objStdOut = objTraceRtExec.StdOut
  64.         While Not objStdOut.AtEndOfStream
  65.             strLine = objStdOut.ReadLine
  66.             objOutputFile.Write strLine & vbCrLf
  67.         Wend
  68.         objTraceRtExec.Terminate
  69.  
  70. objOutputFile.Write " All routers addresses between computer and www.nvidia.ru: " & vbCrLf
  71.         Set objTraceRtExec = objShell.Exec("tracert www.nvidia.ru")
  72.         Set objStdOut = objTraceRtExec.StdOut
  73.         Set list = CreateObject("Scripting.Dictionary")
  74.         While Not objStdOut.AtEndOfStream
  75.             strLine = objStdOut.ReadLine
  76.             objOutputFile.Write strLine & vbCrLf
  77.             startLine = strLine
  78.             isFirst = true
  79.             isTooSlow = false
  80.             If Left(strLine,5) <> "     " Then
  81.                 If Left(strLine,1) = " " Then
  82.                     loopNumber = 0
  83.                     While loopNumber <> 6
  84.                         strLine = Ltrim(strLine)
  85.                         strLine = Rtrim(strLine)
  86.                         n = ""
  87.                         While Left(strLine,1) <> " "
  88.                             n = n & Left(strLine,1)
  89.                             strLine = Right(strLine,Len(strLine)-1)
  90.                         Wend
  91.                         If isFirst <> true Then
  92.                             If IsNumeric(n) Then
  93.                                 resp_time = CInt(n)
  94.                                 If resp_time > 20 Then
  95.                                     isTooSlow = true
  96.                                 End If
  97.                             End If
  98.                         Else
  99.                             isFirst = false
  100.                         End If
  101.                         loopNumber = loopNumber + 1
  102.                     Wend
  103.                 End If
  104.             End If
  105.             If isTooSlow = True Then
  106.                 list.Add startLine, startLine
  107.             End If
  108.         Wend
  109.         objTraceRtExec.Terminate
  110.  
  111.  
  112. 'objOutputFile.Write "5. Network bandwidth: "& vbCrLf
  113. '       Set objShell = CreateObject("WScript.Shell")
  114.         'Set objServExec = objShell.Exec("iperf3 -s")
  115.         'Set objClientExec = objShell.Exec("iperf3 -c" & strIP)
  116. '       Set objStdOut = objClientExec.StdOut
  117. '       While Not objStdOut.AtEndOfStream
  118. '           strLine = objStdOut.ReadLine
  119. '           objOutputFile.Write strLine & vbCrLf
  120. '       Wend
  121. '       objClientExec.Terminate
  122. '       objServExec.Terminate
  123.    
  124.  
  125. Set objTraceRtExec = objShell.Exec("arp -a")
  126.         Set objStdOut = objTraceRtExec.StdOut
  127.         While Not objStdOut.AtEndOfStream
  128.             strLine = objStdOut.ReadLine
  129.             objOutputFile.Write strLine & vbCrLf
  130.         Wend
  131.         objTraceRtExec.Terminate
  132.  
  133. Set objTraceRtExec = objShell.Exec("netstat -n")
  134.         Set objStdOut = objTraceRtExec.StdOut
  135.         While Not objStdOut.AtEndOfStream
  136.             strLine = objStdOut.ReadLine
  137.             objOutputFile.Write strLine & vbCrLf
  138.         Wend
  139.         objTraceRtExec.Terminate
  140.  
  141. isNotMaxMTU = true
  142.         buffSize = 1450
  143.         While isNotMaxMTU
  144.             Set pingResults = objMgmt.ExecQuery("SELECT * FROM Win32_PingStatus WHERE Address = 'www.nvidia.ru' and BufferSize = " & CStr(buffSize) & " and NoFragmentation = true")
  145.             For Each pingResult in pingResults
  146.                 If pingResult.StatusCode = 0 Then
  147.                     objOutputFile.Write "Response time for " & Cstr(buffSize) & " bytes: " & pingResult.ResponseTime & " ms" & vbCrLf  
  148.                     buffSize = buffSize + 1
  149.                 ElseIf pingResult.StatusCode = 11009 Then
  150.                     buffSize = buffSize - 1
  151.                     objOutputFile.Write "Max MTU of nvidia: " & CStr(buffSize) & vbCrLf
  152.                     isNotMaxMTU = false
  153.                 ElseIf buffSize > 1500 Then
  154.                     isNotMaxMTU = false
  155.                     objOutputFile.Write "Something went wrong and MTU stayed unknown" & vbCrLf
  156.                 Else
  157.                     buffSize = buffSize + 1
  158.                 End If
  159.             Next
  160.         Wend
  161.        
  162.        
  163.         Set objTraceRtExec = objShell.Exec("notepad " & outFilePath)
  164.        
  165.         Exit For
  166.  
  167.  
  168. end if
  169. next
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement