Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question'------------------------------------------------------------------------------- ' DELETTE ALL THE NETWORK PRINTERS '------------------------------------------------------------------------------- Set oNet = CreateObject ("Wscript.Network") Set oPrt = oNet.EnumPrinterConnections For i = 0 to oPrt.Count - 1 Step 2 If Left (oPrt.Item(i+1), 1) = "" Then oNet.RemovePrinterConnection oPrt.Item(i+1) End If Next '------------------------------------------------------------------------------- ' LOCAL NETWORK IP '------------------------------------------------------------------------------- strComputer = "." Set objWMIService = GetObject("winmgmts:" & "!\" & strComputer & "\root\cimv2" ) Set colAdapters objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled True" ) For Each objAdapter in colAdapters IPdebut = LBound(objAdapter.IPAddress) IPfin = UBound(objAdapter.IPAddress) If (objAdapter.IPAddress(IPdebut) <> "" ) then For i = IPdebut To IPfin strIPAddress = objAdapter.IPAddress(i) & vbCrLf Next End If Next Public Function ip2num(IP) 'ipv4-only Dim i, a, N a = Split(ip, ".") N = CDbl(0) For i = 0 To UBound(a) N = N * 256 + a(i) Next ip2num = N End Function '------------------------------------------------------------------------------- ' MAP LOCAL NETWORK PRINTERS - L'HORME '------------------------------------------------------------------------------- If ip2num(strIPAddress) >= ip2num("192.33.54.1")_ And ip2num(strIPAddress) <= ip2num("192.33.54.254") Then Set WshNetwork = CreateObject ("WScript.Network") on error resume next PrinterPath = "\\eufrlhoimp01\impfrlho025" WshNetwork.RemovePrinterConnection PrinterPath, true, true WshNetwork.AddwindowsPrinterConnection (PrinterPath) PrinterPath = "\\eufrlhoimp01\impfrlho059" WshNetwork.RemovePrinterConnection PrinterPath, true, true WshNetwork.AddwindowsPrinterConnection (PrinterPath) 'Else ' other fonction End If
bonneCarte=-1 For i = 0 to nbCartes-1 Si ipValide Alors bonneCarte=i Fin FOR Fin si Next i Si bonneCarte=-1 Then End 'pas trouvée, on quitte IP = cartes(bonneCarte).ip
Public Function getFirstIP() 'As String Dim adapters, adap, i adapters = XXXXXXXX For Each adap In adapters For i = 0 To UBound(adap.IPAddress) ''SI IP NON VIDE ALORS RETOURNE CETTE IP Next 'i Next 'adap End Function
'Code non testé, devrait aller ... Public Function ip2long() 'coller le contenu véritable de ma fonction à partir du lien fourni 'Les lignes ajoutées se terminent par un +. 'Comme tu peux le voir y'en a pas des masses Public Function getFirstIP() 'As String 'Remballe la première IP trouvée sur toutes les interfaces réseau de la machine locale 'Si aucune IP n'est trouvée, renvoie une chaine vide. Dim adapters, adap, i, wmi Set wmi = GetObject("winmgmts:!\\.\root\cimv2") '+ Set adapters wmi.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled True") '+ For Each adap In adapters For i = 0 to UBound(adap.IPAddress) If Len(adap.IPAddress(i)) Then getFirstIP = adap.IPAddress(i) '+ Exit Function 'on quitte '+ End If Next 'i Next 'adap End Function monIP = ip2long(getFirstIP()) If monIP = 0 Then MsgBox "Pas d'IP trouvée" End 'pas besoin d'aller plus loin End If 'comparer et installer les imprimantes
If Len(adap.IPAddress(i)) And adap.IPAddress(i)<>"0.0.0.0" Then