Win2K Detect Default Printer? 
Author Message
 Win2K Detect Default Printer?

I'm trying to find the default printer for XP and Win2000 computers on the
domain. WMI works great for XP but .Default is not supported under Win2000.
So I've been looking through script56.chm but I can't find a way to
determine default printer.

I'm running this in logon script...it runs local on each workstation.

Here is code I used that works for XP but not Win2000...

Set oWMIsvc    = GetObject("winmgmts:\\.\root\cimv2")
Set colPrinters = oWMIsvc.ExecQuery("Select * from Win32_Printer",,48)
      For Each oThing in colPrinters

             If oThing.Default Then sDefPrinter = oThing.ShareName

      Next

Is there an ADSI solution for W2K? Or am I missing something in plain old
WSH/VBScript? Or is there another WMI solution?

Thanks,
Marty Henderson



Wed, 17 Aug 2005 07:34:54 GMT  
 Win2K Detect Default Printer?

Quote:
> I'm trying to find the default printer for XP and Win2000 computers
> on the domain. WMI works great for XP but .Default is not supported
> under Win2000. So I've been looking through script56.chm but I can't
> find a way to determine default printer.

> I'm running this in logon script...it runs local on each workstation.

> Here is code I used that works for XP but not Win2000...

> Set oWMIsvc    = GetObject("winmgmts:\\.\root\cimv2")
> Set colPrinters = oWMIsvc.ExecQuery("Select * from Win32_Printer",,48)
>       For Each oThing in colPrinters

>              If oThing.Default Then sDefPrinter = oThing.ShareName

You can test the 3rd ordinal bit of the Attributes property with

      If oThing.Attributes And 2^(3-1) Then sDefPrinter = oThing.ShareName

Quote:

>       Next

> Is there an ADSI solution for W2K? Or am I missing something in plain
> old WSH/VBScript? Or is there another WMI solution?

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US

Technet Script Center
http://www.microsoft.com/technet/scriptcenter/default.asp



Wed, 17 Aug 2005 09:51:11 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Win2K Detect Default Printer?

2. Detect default printer on local LPT1 via VB script

3. Set LOCAL Printer as default printer

4. Detecting default mail client

5. Redmon 1.7 not Redirecting to Win2k Printer

6. Adding printers in Win2k

7. Adding IP enabled printer to Win2k machine

8. Automating Printer Install in win2k and winNT

9. Connect Win98 shared printers to Win2k workstation

10. Differences between runnine WSH on Win2K Pro and Win2K Server

11. Setting Printer Defaults based on Computer Name

12. client side default printer

 

 
Powered by phpBB® Forum Software