|
| Débuté par philippe.pasquali, 22 déc. 2004 18:16 - 1 réponse |
| |
| | | |
|
| |
| Posté le 22 décembre 2004 - 18:16 |
Bonjour,
Existe-t-il l'équivalent de iListeImprimante() mais pour une station/serveur d'un réseau ? Si non, qui as déjà fait une transcription d'un script tel que le suivant qui répond presque à se ke j'veux faire.......
Dim shell, fso, attr, desc, net, args Set shell = WScript.CreateObject("WScript.Shell") Set fso = WScript.CreateObject("Scripting.FileSystemObject") Set net = Wscript.CreateObject("WScript.Network") Set args = Wscript.Arguments
If args.count = 0 Then computer = net.computername Else computer = args(0) If computer = "/?" Then msg = "énumére les imprimantes locales ou réseau" & VBCRLF msg = msg & "d'une machine locale ou distante" & VBCRLF msg = msg & "---------------------------------------------" & VBCRLF msg = msg & "Syntaxe :" & VBCRLF msg = msg & " enumprinter [<nom_de_machine>]" & VBCRLF msg = msg & "Parame :" & VBCRLF msg = msg & " <nom_de_machine> : nom NetBIOS de l'ordinateur" & VBCRLF msg = msg & " si absent : machine locale" & VBCRLF wscript.echo msg wscript.quit End If End If
attr = array(1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192) desc = array( _ "Les travaux d'impression sont mis file d'attente", _ "Les documents sont envoyés directement 'imprimante", _ "Imprimante par défaut de l'ordinateur", _ "Disponible en tant que ressource réseau partagé", _ "Attachée au réseau", _ "Caché pour certains utilisateurs du réseau", _ "Directement connecté'ordinateur", _ "Mise en file d'attente activé si imprimante disponible", _ "Le spooler ne supprime pas les documents aprimpression", _ "Commence en premier les travaux qui sont en fin de spool", _ "Mise en file d'attente activsi imprimante indisponible", _ "Active l'impression bidirectionnelle", _ "Seuls les travaux de type de donnée brut sont spoolée", _ "Imprimante publiée dans le service d'annuaire du réseau")
on error resume next
set PrinterSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//" & Computer).ExecQuery ("SELECT * FROM Win32_Printer")
If err.number <> 0 Then wscript.echo "Erreur : " & err.description wscript.quit End If
msg = "Imprimantes disponibles sur " & ucase(computer) wscript.echo msg wscript.echo String(len(msg),"-") num = 0
for each Printer in PrinterSet num = num+1 wscript.echo wscript.echo FormatStrR(num,2) & ")--- " & Printer.Caption & " ---" Attrib = Cint(Printer.Attributes) firstattr = true For i=lbound(attr) To ubound(attr) If (Attrib and attr(i)) = attr(i) Then If firstattr then prompt = " Attributs : " firstattr = false else prompt = " " End if wscript.echo prompt & desc(i) End If Next wscript.echo " Driver : " & Printer.DriverName wscript.echo " Port : " & Printer.PortName If Printer.Location <> "" Then wscript.echo " Emplacement : " & Printer.Location if Printer.ShareName <> "" Then wscript.echo " Nom de partage : " & Printer.ShareName next
Wscript.quit |
| |
| |
| | | |
|
| | |
| |
| Posté le 05 janvier 2005 - 16:34 |
Réponse à moi même mais si quelqu'un possédant un réseau peut me le tester pServeurName = nom du serveur sous la forme \\<nom du serveur>> on récupére dans ListePrinter=<PrinterName>TAB<TypeImprimante>TAB<Propriétaire>TAB<lieux>RC.. .....
CONSTANT PRINTER_ENUM_CONNECTIONS = 0x04 PRINTER_ENUM_DEFAULT = 0x1 PRINTER_ENUM_LOCAL = 0x2 PRINTER_ENUM_NAME = 0x8 PRINTER_ENUM_NETWORK = 0x40 PRINTER_ENUM_REMOTE = 0x10 PRINTER_ENUM_SHARED = 0x20
// Pour level PRINTER_INFO_1 = 1 PRINTER_INFO_2 = 2 END
PROCEDURE bListePrinterNetwork(pServeurName) Flags est un entier = 0x8 lpName est une chaîne ASCIIZ sur 10240 = pServeurName Level est un entier = PRINTER_INFO_2 iBuffer est un tableau dynamique de 0 entier iBufferSize est entier = 100000 iBufferRequired est un entier = 0 iEntries est un entier = 0 i, j sont des entiers pPrinter est un entier strPrinterName, strModele, strProprietaire, strLieux sont des chaînes ASCIIZ sur 1024
ListePrinter est une chaîne = ""
Dimension(iBuffer,iBufferSize)
IF AppelDLL32("winspool.drv", "EnumPrintersA" , Flags, lpName, Level, &iBuffer[1], iBufferSize, &iBufferRequired, &iEntries) THEN FOR i=1 TO iEntries
// Nom complet de l'imprimante j = iBuffer[((i-1)*21)+2] WHEN EXCEPTION IN Transfert(&strPrinterName,j,1023) DO strPrinterName ="" END
IF strPrinterName<>"" THEN // Modéle j = iBuffer[((i-1)*21)+5] WHEN EXCEPTION IN Transfert(&strModele,j,1023) DO strModele ="" END // Propiétaire j = iBuffer[((i-1)*21)+6] WHEN EXCEPTION IN Transfert(&strProprietaire,j,1023) DO strProprietaire ="" END // Lieux j = iBuffer[((i-1)*21)+7] WHEN EXCEPTION IN Transfert(&strLieux,j,1023) DO strLieux ="" END IF ListePrinter<>"" THEN ListePrinter += RC ListePrinter += (strPrinterName+TAB+strModele+TAB+strLieux+TAB+strProprietaire) END
END END
RENVOYER ListePrinter
"Philippe Pasquali" <philippe.pasquali@bopack.com> a écrit dans le message de news:41c994cb@news.pcsoft.fr...
Bonjour,
Existe-t-il l'équivalent de iListeImprimante() mais pour une
station/serveur
d'un réseau ? Si non, qui as déjà fait une transcription d'un script tel que le suivant qui répond presque à se ke j'veux faire.......
Dim shell, fso, attr, desc, net, args Set shell = WScript.CreateObject("WScript.Shell") Set fso = WScript.CreateObject("Scripting.FileSystemObject") Set net = Wscript.CreateObject("WScript.Network") Set args = Wscript.Arguments
If args.count = 0 Then computer = net.computername Else computer = args(0) If computer = "/?" Then msg = "énumére les imprimantes locales ou réseau" & VBCRLF msg = msg & "d'une machine locale ou distante" & VBCRLF msg = msg & "---------------------------------------------" & VBCRLF msg = msg & "Syntaxe :" & VBCRLF msg = msg & " enumprinter [<nom_de_machine>]" & VBCRLF msg = msg & "Parame :" & VBCRLF msg = msg & " <nom_de_machine> : nom NetBIOS de l'ordinateur" & VBCRLF msg = msg & " si absent : machine locale" & VBCRLF wscript.echo msg wscript.quit End If End If
attr = array(1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192) desc = array( _ "Les travaux d'impression sont mis file d'attente", _ "Les documents sont envoyés directement 'imprimante", _ "Imprimante par défaut de l'ordinateur", _ "Disponible en tant que ressource réseau partagé", _ "Attachée au réseau", _ "Caché pour certains utilisateurs du réseau", _ "Directement connecté'ordinateur", _ "Mise en file d'attente activé si imprimante disponible", _ "Le spooler ne supprime pas les documents aprimpression", _ "Commence en premier les travaux qui sont en fin de spool", _ "Mise en file d'attente activsi imprimante indisponible", _ "Active l'impression bidirectionnelle", _ "Seuls les travaux de type de donnée brut sont spoolée", _ "Imprimante publiée dans le service d'annuaire du réseau")
on error resume next
set PrinterSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//" &
Computer).ExecQuery ("SELECT * FROM Win32_Printer")
If err.number <> 0 Then wscript.echo "Erreur : " & err.description wscript.quit End If
msg = "Imprimantes disponibles sur " & ucase(computer) wscript.echo msg wscript.echo String(len(msg),"-") num = 0
for each Printer in PrinterSet num = num+1 wscript.echo wscript.echo FormatStrR(num,2) & ")--- " & Printer.Caption & " ---" Attrib = Cint(Printer.Attributes) firstattr = true For i=lbound(attr) To ubound(attr) If (Attrib and attr(i)) = attr(i) Then If firstattr then prompt = " Attributs : " firstattr = false else prompt = " " End if wscript.echo prompt & desc(i) End If Next wscript.echo " Driver : " & Printer.DriverName wscript.echo " Port : " & Printer.PortName If Printer.Location <> "" Then wscript.echo " Emplacement : " & Printer.Location if Printer.ShareName <> "" Then wscript.echo " Nom de partage : " & Printer.ShareName next
Wscript.quit
|
| |
| |
| | | |
|
| | | | |
| | |
|