Submitted by PhilEddies on Mon, 04/04/2011 - 18:20administrator | 4563 points
The below little VBS script is an example of how to pull back a list of network printers a users is connected to.
This script is only pulling back the server and share names but you could retrieve other properties in the same way
http://msdn.microsoft.com/en-us/library/aa394363%28v=vs.85%29.aspx
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colPrinters = objWMIService.ExecQuery ("Select * From Win32_Printer Where Local = False")
If colPrinters.Count <> 0 Then'If there are some network printers
ForEach objPrinterInstalled In colPrinters ' For each network printer
msgbox objPrinterInstalled.ServerName & "\"& objPrinterInstalled.ShareName ' Show the server\shar name
Next
Endif
Set colPrinters = objWMIService.ExecQuery ("Select * From Win32_Printer Where Local = False")
If colPrinters.Count <> 0 Then'If there are some network printers
ForEach objPrinterInstalled In colPrinters ' For each network printer
msgbox objPrinterInstalled.ServerName & "\"& objPrinterInstalled.ShareName ' Show the server\shar name
Next
Endif
Attachment | Size |
---|---|
![]() | 388 bytes |