Dim wshShell, strCmd, oRep, strReponse Set wshShell = CreateObject("WScript.Shell") strCmd = "cmd.exe /C ver" Set oRep = wshShell.Exec(strCmd) strReponse = Trim(oRep.StdOut.ReadAll) If (Replace(strReponse, "Windows XP", "") = strReponse) Then WScript.Quit 0 End if strComputer = "." Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\cimv2") Set colInstalledPrinters = objWMIService.ExecQuery _ ("Select * From Win32_Printer") For Each objPrinter in colInstalledPrinters If objPrinter.Portname = "\\serveur\imprimante" Then objPrinter.Delete_ End If Next
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionstrComputer = "." Set objWMIService = GetObject("winmgmts:" & _ "{impersonationLevel=impersonate}!\" & strComputer & "\root\cimv2") Set colOS = objWMIService.ExecQuery(_ "Select * from Win32_OperatingSystem") For Each objOS in colOS If InStr(objOS.Caption, "XP") Then Set WshNetwork = WScript.CreateObject("WScript.Network") Set oPrinters = WshNetwork.EnumPrinterConnections For i = 0 to oPrinters.Count - 1 Step 2 WScript.Echo objOS.Caption & vbcr & _ "Port " & oPrinters.Item(i) & _ " = " & oPrinters.Item(i+1) Next Set WshNetwork = Nothing Set oPrinters = Nothing End if Next Set objWMIService = Nothing Set colOS = Nothing
strComputer = "." Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\cimv2") Set colInstalledPrinters = objWMIService.ExecQuery _ ("Select * From Win32_Printer") For Each objPrinter in colInstalledPrinters If objPrinter.Portname = "\\serveur\imprimante" Then objPrinter.Delete_ End If