Solved

Scripting Printer settings

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
Scenerio: You have a server running Server 2003 and have applied a retail pack of Terminal Server Licenses.  You want to change servers or your server has crashed and you need to reapply the Terminal Server Licenses. When you enter the 16-digit lic…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

810 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