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
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