Hello,

I have a script that finds the network printers and stores them. I want the script to tell me which one in the default printer. Weather its a network or stand alone printer(usb) as default

Const ForWriting = 2

Set objNetwork = CreateObject("Wscript.Network")

strName = objNetwork.UserName
strDomain = objNetwork.UserDomain
strUser = strDomain & "\" & strName

strText = strUser & vbCrLf

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colPrinters = objWMIService.ExecQuery _
    ("Select * From Win32_Printer Where Local = FALSE")

For Each objPrinter in colPrinters
    strText = strText & objPrinter.Name & vbCrLf
Next

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.CreateTextFile _
    ("C:\kbox\Printers.txt", ForWriting, True)

objFile.Write strText

objFile.Close

0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Community Chosen Answer

1
use wmic and run as a kscript to create a file, then read the files in as CIR's

here are the 3 wmic calls I run, the first is network only, the second is local only, the third is both.

wmic printer where 'network="true"' get name, default, network > C:\ProgramData\Dell\KACE\user\NetworkPrinters.txt

wmic printer where "network=false and NOT DriverName LIKE '%%WebEx%%' and NOT DriverName LIKE '%%Amyuni%%' and NOT DriverName LIKE '%%Microsoft%%' and NOT DriverName LIKE '%%PDF%%' and NOT DriverName LIKE '%%Adobe%%' and NOT DriverName LIKE '%%Hyland%%' and NOT DriverName LIKE '%%snagit%%'" get name,drivername,printerstatus,default > C:\ProgramData\Dell\KACE\user\LocalPrinters.txt

wmic printer where "NOT DriverName LIKE '%%WebEx%%' and NOT DriverName LIKE '%%Amyuni%%' and NOT DriverName LIKE '%%Microsoft%%' and NOT DriverName LIKE '%%PDF%%' and NOT DriverName LIKE '%%Adobe%%' and NOT DriverName LIKE '%%Hyland%%' and NOT DriverName LIKE '%%snagit%%'" get name,drivername,portname, default > C:\ProgramData\Dell\KACE\user\AllPrinters.txt

http://www.itninja.com/blog/view/create-cirs-to-show-current-users-mapped-drives-and-networled-printers-presented-at-dell-world-user-forum-2014-lessions-from-the-field

also see

http://www.itninja.com/blog/view/k1000-custom-inventory-rule-to-inventory-local-network-printers
Answered 05/04/2016 by: SMal.tmcc
Red Belt

  • of course the not like commands need to be tuned for your environment to remove those crappy not really a printer printers windows installs
Please log in to comment

Answers

0
Also, remember that printers are user resources, not machine resources so your interrogation needs to be conducted as the logged-in user.
Answered 05/05/2016 by: VBScab
Red Belt

  • network printers are user resources while local printers are machine resources
Please log in to comment
Answer this question or Comment on this question for clarity