PC Review Forums Newsgroups Windows XP Windows XP WMI query print driver

Reply

query print driver

 
Thread Tools Rate Thread
Old 25-07-2004, 06:57 AM   #1
Jeff
Guest
 
Posts: n/a
Default query print driver


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
  Reply With Quote
Old 25-07-2004, 02:05 PM   #2
Torgeir Bakken \(MVP\)
Guest
 
Posts: n/a
Default Re: query print driver

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
  Reply With Quote
Old 25-07-2004, 03:25 PM   #3
jeff
Guest
 
Posts: n/a
Default Re: query print driver

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

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off