Solved

Scripting Printer settings

Posted on 2012-03-22
5
1,164 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 500 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

627 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