PC Review
Forums
Newsgroups
Windows XP
Windows XP WMI
query print driver
Forums
Newsgroups
Windows XP
Windows XP WMI
query print driver
![]() |
query print driver |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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 |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Jeff wrote:
> 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 -- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: http://www.microsoft.com/technet/sc...er/default.mspx |
|
|
|
#3 |
|
Guest
Posts: n/a
|
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 >-----Original Message----- >Jeff wrote: > >> 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 > > > >-- >torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway >Administration scripting examples and an ONLINE version of >the 1328 page Scripting Guide: >http://www.microsoft.com/technet/sc...ter/default.msp x >. > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

