Informations réseau (VBScript)

Le script suivant affiche une boîte de message avec les informations réseau, comme un ipconfig sous DOS.


Code VisualBASIC ou VBA ou VBS (script vbs : ipconfig) (34 lignes) :
  1. Dim strComputer
  2. Dim colDrives, strMsg
  3. Dim WSHNetwork
  4. strComputer = "."
  5. Set NetworkPROP = WScript.CreateObject("WScript.Network")
  6. Set objWMIService = GetObject _
  7. ("winmgmts:" & "!\" & strComputer & "\root\cimv2")
  8. Set colAdapters = objWMIService.ExecQuery _
  9. ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")
  10. For Each objAdapter in colAdapters
  11.   Msgbox "UserName " & vbTab & "=" & NetworkPROP.UserName & vbCrLf & _
  12.   "Host name: " & vbTab & "=" & objAdapter.DNSHostName & vbCrLf & _
  13.   "IP address: " & vbTab & "=" & objAdapter.IPAddress(i) & vbCrLf & _
  14.   "Description: " & vbTab & "=" & objAdapter.Description & vbCrLf & _
  15.   "User Domain: " & vbTab & "=" & NetworkPROP.UserDomain & vbCrLf & _
  16.   "Physical address: " & vbTab & "=" & objAdapter.MACAddress & vbCrLf & _
  17.   "DHCP enabled: " & vbTab & "=" & objAdapter.DHCPEnabled, _
  18.   vbinformation + vbOKOnly + vbmsgboxsetforeground, _
  19.   "PROPRIETES RESEAU "
  20. Next
  21. Set colDrives = NetworkPROP.EnumNetworkDrives
  22. If colDrives.Count = 0 Then
  23.   MsgBox "AUCUN LECTEUR RESEAU ACTIF.", _
  24.   vbInformation + vbOkOnly, _
  25.   L_Welcome_MsgBox_Title_Text
  26. Else
  27.   strMsg = "CONNECTIONS ACTIVES : " & vbCrLf
  28.   For i = 0 To colDrives.Count - 1 Step 2
  29.     strMsg = strMsg & vbCrLf & colDrives(i) & vbTab & colDrives(i + 1)
  30.   Next
  31.   MsgBox strMsg, _
  32.   vbInformation + vbOkOnly, _
  33.   "CONNECTIONS RESEAU"
  34. End If

Contents Haut

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 11/06/2004, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/vbs-ipconfig.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.