Solved

Scripting Printer settings

Posted on 2012-03-22
5
1,055 Views
Last Modified: 2012-08-13
I am looking to alter a setting on Windows printers installed on a 2003R2 print server to ensure that the following setting is properly configured:
"(radio button) Print spooled documents first"

I've been directed to the following script prncnfg.vbs located at %WINDIR%\System32\Printing_Admin_Scripts\ with this parameter:
[{+ | -}docompletefirst]

Now this appears at first glance to be what I want however it doesn't seem to allow me to do this on multiple printers.

Is there a better option as far as automating this?   There are a LOT of printers I need to ensure that this is set on.  And I have a hard time believing the only way to do this is for me to touch EACH individual Queue.
0
Comment
Question by:Lahru
  • 2
  • 2
5 Comments
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
Hi, if you have the command for prncnfg.vbs that ticks this setting for you for one printer, we can easily run a loop on all printers on a print server to set that setting.

Regards,

Rob.
0
 
LVL 3

Expert Comment

by:BigRedRPB
Comment Utility
Try this VBS script.  I tested on Win7 and it worked fine but you'll need to give it a shot on 2003.  If it doens't work, it won't hurt anything, it just won't work.  :)  Also, keep in mind that it will change EVERY printer it find (including Adobe PDF, etc.) which may or may not matter.


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

Set colItems = objWMIService.ExecQuery("Select * From Win32_Printer")

For Each objItem in colItems
    objItem.DoCompleteFirst = 1
    objItem.Put_
Next
0
 

Author Comment

by:Lahru
Comment Utility
It looks like the VB Script code is what I am after and it works on both Win7 and Win2k3 if run by itself however the difficulty I am running into now is that I've added it to another script and when I run it I get:

C:\InstallPrinters.vbs(347, 16) Microsoft VBScript compilation error: Expected 'Next'

if I do add NEXT, then I get:

C:\InstallPrinters.vbs(207, 1) SWbemObjectEx: Generic failure

The last error I get is after 3 of 12 printers have been added.

Without the code to check that box "Print spooled documents first" then this option is NOT checked, but all of the printers add.

I've tried using boh Wscript & Cscript but there is no difference there.
0
 
LVL 3

Expert Comment

by:BigRedRPB
Comment Utility
Without seeing your entire script, it's hard to troubleshoot that error.  I see that the line numers it's failiing on are pretty far apart so you've obviously got a good bit of code in that script.  Interesting that you have to check this at all on new installs, my printers all seem to have this by default.

Alright, if you aren't already doing it, I would try running your install function first to allow all of the printers to install, then maybe putting a wscript.sleep 5000 in to have it sleep for 5 seconds before running the chunk of code that I posted.  Perhaps it takes a little time for WMI to update and the script is just running too fast.

If that doesn't work, and you want to post your code, I'm happy to take a look.
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
Comment Utility
Since your script appears to be adding printers, you probably have something like
Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_

objPrinter.DriverName = PrnDrv
objPrinter.PortName = PortName
objPrinter.DeviceID = PrnName
objPrinter.Location = PrnLocation
objPrinter.Comment = PrnComment
objPrinter.Network = True
objPrinter.Put_

Open in new window


so in that section, just above the .Put_ add objPrinter.DoCompleteFirst = 1

and that should do that setting for you.  Then you won't need the extra loop.

Regards,

Rob.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now