Solved

Scripting Printer settings

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Recently, I had the need to build a standalone system to run a point-of-sale system. I’m running this on a low-voltage Atom processor, so I wanted a light-weight operating system, but still needed Windows. I chose to use Microsoft Windows Server 200…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

861 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

25 Experts available now in Live!

Get 1:1 Help Now