mcmoser
asked on
List printers installed on remote pc
Hello,
I'm trying to figure out how to get a listing of the printers that would be installed on a remote pc using vb. As it stands, i can get this information using batch files, but i'm looking to move away from them as much as possible. I can get the information from my machine strickly using vb, but i can't figure out how to get the information from a remote machine on the same network.
Thanks
I'm trying to figure out how to get a listing of the printers that would be installed on a remote pc using vb. As it stands, i can get this information using batch files, but i'm looking to move away from them as much as possible. I can get the information from my machine strickly using vb, but i can't figure out how to get the information from a remote machine on the same network.
Thanks
ping
Put this on the command button.
Dim devlist as object
Dim dev as object
Set devlist = GetObject("winmgmts:{imper sonationLe vel=impers onate}").E xecQuery(" select * from Win32_Printer")
For Each dev In devlist
msgbox "Printer: " & dev.Name & " " & dev.Location &
Next
devlist = Nothing
************************** ****
here is some article:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_printer.asp
Dim devlist as object
Dim dev as object
Set devlist = GetObject("winmgmts:{imper
For Each dev In devlist
msgbox "Printer: " & dev.Name & " " & dev.Location &
Next
devlist = Nothing
**************************
here is some article:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_printer.asp
ASKER
Computron, i'm gonna have a look at that tomorrow when i go into work. I'll let you know how it went.
JackOfPH, I don't follow what you mean by ping? I know what ping does, but unless i'm mistaken, I don't think it will give me any information on printers?
Appreciate the quick responses!
JackOfPH, I don't follow what you mean by ping? I know what ping does, but unless i'm mistaken, I don't think it will give me any information on printers?
Appreciate the quick responses!
The URL I gave was not very specific, here it is
http://vbnet.mvps.org/code/network/connecttoprinterdlg.htm
http://vbnet.mvps.org/code/network/connecttoprinterdlg.htm
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
DeadlyTrev,
I tried what you suggested and it's working. Is it possible to set a username & password as well into the command?
I tried what you suggested and it's working. Is it possible to set a username & password as well into the command?
ASKER
Think i got it working now.
Set objLocator = CreateObject("WbemScriptin g.SWbemLoc ator")
Set objWMIService = objLocator.ConnectServer(R emoteCompu ter, "root\cimv2", RemoteUsername, RemotePassword)
objWMIService.Security_.im personatio nlevel = 3
Set PrinterList = objWMIService.ExecQuery("S elect * from Win32_Printer")
For Each PrinterInstance In PrinterList
MsgBox PrinterInstance.Name
Next
Set PrinterList = Nothing
Set WMIService = Nothing
Excellent, thanks a lot for all your help.
Set objLocator = CreateObject("WbemScriptin
Set objWMIService = objLocator.ConnectServer(R
objWMIService.Security_.im
Set PrinterList = objWMIService.ExecQuery("S
For Each PrinterInstance In PrinterList
MsgBox PrinterInstance.Name
Next
Set PrinterList = Nothing
Set WMIService = Nothing
Excellent, thanks a lot for all your help.