query print driver

J

Jeff

Hi,
I am trying to write a script to query a network printer
installed locally and then delete it if it is installed
on the local machine and then add a similar printer with
a different network path.
I have tried some IF statements and haven't been
successful. Here is the basic code. Thanks, Jeff
strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer
& "\root\cimv2")

Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer Where DriverName = 'Oce
TDS600'")



Next


'this section should be executed if the Oce TDS600 driver
was found in section above

Set WshNetwork = WScript.CreateObject
("WScript.Network")
PrinterPath = "\\Server\ocetds600-1"
On error resume next
WshNetwork.RemovePrinterConnection PrinterPath,
true, true


PrinterPath = "\\Differentserver\tds600-1"
WshNetwork.AddWindowsPrinterConnection PrinterPath
 
T

Torgeir Bakken \(MVP\)

Jeff said:
Hi,
I am trying to write a script to query a network printer
installed locally and then delete it if it is installed
on the local machine and then add a similar printer with
a different network path.
I have tried some IF statements and haven't been
successful. Here is the basic code. Thanks, Jeff
(snip code)
Hi

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer Where DriverName = 'Oce TDS600'")

If colInstalledPrinters.Count > 0 Then
WScript.Echo "Oce TDS600 driver is installed"
End If
 
J

jeff

Torgeir,
Thanks for the reply. I will try it. I was trying the
true statement and even the is Not statement with no luck.
Thanks again.
Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top