
COME VISUALIZZARE TUTTE LE STAMPANTI INSTALLATE
Con l’esecuzione dello script possiamo visualizzare tutte le stampanti collegate in modo diretto (tramite usb) e in remoto (di rete) al pc con le relative porte di comunicazione.
Copia il codice nel Blocco note e salva con estensione .vbs
Codice
dim objShell,objNetwork,collDrives
set objShell=CreateObject("Wscript.shell")
Set objNetwork=CreateObject("WScript.Network")
strTitle="Stampanti - [https://www.giovannidimauro.it]"
strMappedDrives=EnumNetwork()
strMappedPrint=EnumPrint()
strMsg=objNetwork.UserName & " è il nome dell'Account attualmente in uso, mentre la macchina (il PC) si chiama " &_
objNetwork.ComputerName & VbCrLf & vbcrlf
strMsg=strMsg & strMappedDrives & VbCrLf & VbCrLf
strMsg=strMsg & strMappedPrint & VbCrLf & VbCrLf
strMsg=strMsg & "Attualmente.... " & Now & VbCrLf
objShell.Popup strMsg,10,strTitle,vbOKOnly+vbInformation
WScript.quit
Function EnumNetwork()
On Error Resume Next
Set colDrives = objNetwork.EnumNetworkDrives
If colDrives.Count = 0 Then
ret="Non sono presenti unità di rete in elenco."
Else
ret = "Percorso delle Unità di rete correnti:" & vbCRLF
For i = 0 To colDrives.Count - 1 Step 2
ret = ret & VbCrLf & colDrives(i) & vbTab & colDrives(i + 1)
Next
End If
EnumNetwork=ret
End Function
Function EnumPrint()
On Error Resume Next
Set colPrint = objNetwork.EnumPrinterConnections
If colPrint.Count = 0 Then
ret="Non sono presenti stampanti in elenco."
Else
ret = "Stampanti attualmente collegate: " & vbCRLF
For i = 0 To colPrint.Count - 1 Step 2
ret = ret & vbCRLF & colPrint(i) & vbTab & colPrint(i + 1)
Next
End If
EnumPrint=ret
End Function
5/5 - (3 voti)