Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Scripting Printer settings

Posted on 2012-03-22
5
Medium Priority
?
1,185 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 37755379
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
ID: 37757591
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
ID: 37758101
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
ID: 37758204
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 2000 total points
ID: 37763586
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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

730 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