Question

Scripting a printer driver change

Asked by: netcmh

Hello,

I'm sure this has been dealt with in the past, but I have not been able to find a solution that works. So, please help me get this right.

Situation:

Typical corporation with all kinds of HP, Ricoh and Lexmark printers. Let's focus only on the HPs.

We've got inkjets and laserjets. They're all installed on the print server and the users connect to the printers via the print server (WIndows 2003). Since this was done in increments, all the printers were installed using their own drivers. So, a 3600 was installed with the PCL version of the 3600 driver, a 3800 with a 3800 driver and so on.

I would like to unify them all over a UPD PCL 5 driver. For this I think the steps are as follows (please correct me if I'm wrong):

1. Install the UPD PCL 5 driver on the server side by side with all the existing drivers (which I've done)
2. Write and execute a script to change all the HP printers ONLY on the server start using the new UPD driver
3. Write and execute a script to delete the C:\WINDOWS\system32\spool\drivers\W32x86\3\HPBMINI.dll and C:\WINDOWS\system32\spool\drivers\W32x86\3\HPCDMC32.dll files on the users' computers
4. Write and execute a script to list all the printers on the users' computers and change the drivers of only those installed on the users' computers to the new UPD PCL 5 driver.

Please let me know first if this is the right way, and second how to go about scripting all the codes. http://www.robvanderwoude.com/2kprintcontrol.html might help get some of you started, but I need step by steps.

Thank you for your help.

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-11-03 at 08:17:12ID24867619
Tags

Windows 2003 Printer driver script

Topics

Printers by HP

,

Drivers

,

Windows 2003 Server

Participating Experts
3
Points
0
Comments
18

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Driver for Inkjet
    I have to develop a driver routine for Epson Inkjet printer. Can anyone give me some info or sites on where I can find info on how to develop inkjet printer drivers?
  2. Printer Type: LaserJet or InkJet
    Hi, guys. Is there any Windows API function which tells you that the printer is laserjet or inkjet ? Any other way to find out ? I need to find out, because I'm using GDI objects (VC++ 6.0) to draw graphs and the width pen is displayed differently on different printers (e.g...
  3. Unable to remove printer driver for HP LaserJet 1300 PC…
    Hello, I have a printer driver installed for an HP LaserJet 1300 PCL 5e on a Windows Server 2003, Standard Edition. I am trying to remove the driver from the server. When I go to printers and faxes, right click and got to print server properties, drivers tab, highlight the H...
  4. Is there a driver for HP LaserJet 5L PCL under winXP?
    Is there a driver for HP LaserJet 5L PCL under winXP? I'm replacing a win98 pc (with an HP LaserJet 5L 'pcl' connected to it) with a winXP pc. Where can I get the HP 5L pcl drivers for winXP for it to work correctly?
  5. Lexmark T630 PCL XL Error
    I Have a recently installed Lexmark T630 on a Windows XP Machine. The most recent drivers from the Lexmark Website is installed and when you attempt to Print a Test Page the following error Prints out PCL XL error Subsystem: KERNEL Error: IllegalAttributeDataType ...
  6. printer driver for lexmark
    I cannot find a driver for a lexmark z22 inkjet printer. If someone could show me where to get one I would appreciate it.

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: netcmhPosted on 2009-11-03 at 08:23:49ID: 25730568

A part of the requirement in step 4 is listing the printers. Is achievable by

cscript //nologo %SYSTEMROOT%\SYSTEM32\prnmngr.vbs -l -s localhost

 

by: netcmhPosted on 2009-11-03 at 08:30:33ID: 25730664

One other thing, would be to find out the default printer for the users, and reset the correct printer as the default after the changes. http://www.tech-recipes.com/rx/2568/batch_files_get_users_default_printer_via_registry_winxp/  might help you get started

 

by: netcmhPosted on 2009-11-03 at 11:54:51ID: 25732836

Anyone up for the challenge?

 

by: DansDadUKPosted on 2009-11-03 at 12:49:52ID: 25733438

>> "a 3600 was installed with the PCL version of the 3600 driver"

The LaserJet 3600 printer is a 'host-based' device, which does NOT support PCL5; as such, it requires a special device-specific JetReady driver.

 

by: netcmhPosted on 2009-11-03 at 13:21:06ID: 25733841

So, my 3600s will have to be skipped. How about the rest - the 4250s, 3525s etc.

 

by: DansDadUKPosted on 2009-11-03 at 14:18:43ID: 25734451

The LaserJet 4250 and LaserJet CP3525 printers both support all three of the traditional Page Description Languages (PDLS):

PCL5 (PCL5e for monochrome devices; PCL5c for colour);
PCL6 (aka PCL XL)
PostScript (aka PS)

They both also support 'Direct PDF', provided that a certain minimum amount of memory (128MB, I think) is installed.

Note that most inkjet devices use proprietary languages (e.g. PCL3GUI) which are NOT a complete subset of PCL5; a few of the more expensive business inkjet devices DO support PCL5.

 

by: netcmhPosted on 2009-11-04 at 05:12:27ID: 25738916

ok.... so, how exactly does that help me script a change?

 

by: netcmhPosted on 2009-11-04 at 06:30:26ID: 25739595

Anyone?

 

by: DansDadUKPosted on 2009-11-04 at 06:40:43ID: 25739696

>> " so, how exactly does that help me script a change?"

It doesn't; I was merely attempting to answer your subsidiary question (and pointing out that quite a few printers are not suited to the Universal Print Driver (UPD) mechanism).

 

by: netcmhPosted on 2009-11-04 at 07:08:58ID: 25740052

I'm thoroughly confused now. HP Support swear by UPD 5.0 being the fix for all the issues we've been having - and it's been true so far. Getting all the supported printers onto the UPD 5.0 has been helpful in lesser and lesser spooler crashes, and other issues.

Anyway, I think we'll still go ahead with the script. I'll make the necessary exceptions. Please help me find or build the script.

Thanks

 

by: netcmhPosted on 2009-11-04 at 12:42:41ID: 25743674

Ok, not having heard back from anyone, I decided to try my hand at this. This script works if there is just one printer. Fails when there's 2 or more, which is always the case.

Can someone please look into this batch file and modify it so that it can go through the list of printers and their ports (prns.txt & prts.txt) and run through the rest of the script in tandem - meaning that printer1 with port1, printer2 with port2 and so on.

Thank you for you time.

::===================================================
:: Automated Printer Driver Change
::
:: This batch file was written by NetCMH
::
:: Version 1.0 for Windows XP
::
:: Script to:
:: 1. Enumerate the printers on the computer
:: 2. List the default printer
:: 3. Delete and re-add printers with UPD 5.0 driver
:: 4. Re-establish the default printer
::=================================================== 
@echo off
setLocal EnableDelayedExpansion 
ver | find "2003" > nul
if %ERRORLEVEL% == 0 goto ver_2003 
ver | find "XP" > nul
if %ERRORLEVEL% == 0 goto ver_xp 
ver | find "2000" > nul
if %ERRORLEVEL% == 0 goto ver_2000 
ver | find "NT" > nul
if %ERRORLEVEL% == 0 goto ver_nt 
echo Machine undetermined.
goto exit 
:ver_2003
echo Windows 2003
call :create_temp
call :list_printers
call :list_default_printer
call :process_files
rem call :rename_old_files
call :change_drivers
call :cleanup
goto :eof 
:ver_xp
echo Windows XP
call :create_temp
call :list_printers
call :list_default_printer
call :process_files
rem call :rename_old_files
call :change_drivers
call :cleanup
goto :eof 
:ver_2000
echo Windows 2000: Not supported in this version
goto :eof 
:ver_nt
echo Windows NT: Not supported in this version
goto :eof 
:create_temp
if exist "C:\temp\" (
echo. Folder Exists
) else (
mkdir c:\temp\
)
exit /b 
:list_printers
echo Listing printers & ports to text files : c:\temp\prns.txt & c:\temp\prts.txt
cscript //nologo %SYSTEMROOT%\SYSTEM32\prnmngr.vbs -l | findstr /c:"Printer name" | findstr /v "Microsoft" >>  
c:\temp\prns.txt
cscript //nologo %SYSTEMROOT%\SYSTEM32\prnmngr.vbs -l | findstr /c:"Port name" | findstr /v "Microsoft" >> c:\temp\prts.txt
exit /b 
:list_default_printer
echo Listing default printer to text file : c:\temp\defprn.txt
cscript //nologo %SYSTEMROOT%\SYSTEM32\prnmngr.vbs -g >> c:\temp\defprn.txt
exit /b 
:process_files
echo Processing files to extract variables
FOR /F "tokens=1 delims=" %%A in ('type c:\temp\prns.txt') do SET myVar1=%%A
set myvar1=%myvar1:Printer name =%
FOR /F "tokens=1 delims=" %%A in ('type c:\temp\prts.txt') do SET myVar2=%%A
set myvar2=%myvar2:Port name =%
FOR /F "tokens=1 delims=" %%A in ('type c:\temp\defprn.txt') do SET myVar3=%%A
set myvar3=%myvar3:The default printer is =%
exit /b 
:rename_old_files
ren C:\WINDOWS\system32\spool\drivers\w32x86\3\HPBMINI.dll C:\WINDOWS\system32\spool\drivers\w32x86\3\OLD_HPBMINI.dll
ren C:\WINDOWS\system32\spool\drivers\w32x86\3\HPCDMC32.dll C:\WINDOWS\system32\spool\drivers\w32x86\3\OLD_HPCDMC32.dll
exit /b 
:change_drivers
echo Changing Drivers:
for /f "tokens=* delims= " %%a in (c:\temp\prns.txt) do (
cd %SystemRoot%\system32
echo Deleting exisiting UPD 5.0 driver if exists
Cscript Prndrvr.vbs -d -m "HP Universal Printing PCL 5 (v5.0)" -v 3 -e "Windows NT x86"
echo Installing fresh UPD 5.0 driver from server
rundll32 printui.dll,PrintUIEntry /ia /m "HP Universal Printing PCL 5 (v5.0)" /f "\\server01\upd5pcl5\hpcu091b.inf" /u
echo Deleting printers
Cscript Prnmngr.vbs -d -p "%myvar1%"
echo Adding printers
cscript prnmngr.vbs -ac -p "%myvar1%" -m "HP Universal Printing PCL 5 (v5.0)" -r "%myvar2%"
echo Re-instating the default printer
Cscript Prnmngr.vbs -t -p "%myvar3%"
if errorlevel 1 (echo %%a >> c:\temp\failed.txt
) else (
echo Success
)
) 
:cleanup
echo Cleaning up
echo y|del c:\temp\prns.txt
echo y|del c:\temp\prts.txt
echo y|del c:\temp\defprn.txt 
:eof
exit

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:

Select allOpen in new window

 

by: netcmhPosted on 2009-11-04 at 13:53:21ID: 25744364

Anyone?

 

by: eruvePosted on 2009-11-05 at 07:39:25ID: 25750617

Since we are always considering improving our own environment, I'm curious about this as well.  

May I ask why you chose the UPD PCL 5 driver over others?

 

by: netcmhPosted on 2009-11-05 at 07:57:58ID: 25750811

HP support say it's their silver bullet for our issues of print spooler crashes.

 

by: netcmhPosted on 2009-11-05 at 10:45:20ID: 25752526

Done. Not a programmer or even a professional scripter. So please use caution if using

::===================================================
:: Automated Printer Driver Change
::
:: This batch file was written by NetCMH
::
:: Version 1.0 for Windows XP
::
:: Script to:
:: 1. Enumerate the printers on the computer
:: 2. List the default printer
:: 3. Delete and re-add printers with UPD 5.0 driver
:: 4. Re-establish the default printer
::=================================================== 
@echo off
setLocal EnableDelayedExpansion 
Rem Querying what OS the batch file's being called from
ver | find "2003" > nul
if %ERRORLEVEL% == 0 goto ver_2003 
ver | find "XP" > nul
if %ERRORLEVEL% == 0 goto ver_xp 
ver | find "2000" > nul
if %ERRORLEVEL% == 0 goto ver_2000 
ver | find "NT" > nul
if %ERRORLEVEL% == 0 goto ver_nt 
echo Machine undetermined.
goto eof 
:ver_2003
echo Windows 2003: Not supported in this version
goto :eof 
:ver_xp
echo Windows XP
call :create_temp
call :list_default_printer
call :create_printerportvbs
call :change_drivers
call :cleanup
goto :eof
 
:ver_2000
echo Windows 2000: Not supported in this version
goto :eof 
:ver_nt
echo Windows NT: Not supported in this version
goto :eof 
:create_temp
Rem Creating a c:\temp folder if it does not exist
if exist "C:\temp\" (
echo Temp Folder Exists
) else (
mkdir c:\temp\
)
exit /b 
:list_default_printer
Rem Listing and storing the default printer
echo Listing default printer to text file : c:\temp\defprn.txt
cscript //nologo %SYSTEMROOT%\SYSTEM32\prnmngr.vbs -g >> c:\tempdefprn.txt
FOR /F "tokens=1 delims=" %%A in ('type c:\temp\defprn.txt') do SET myVar3=%%A
set myvar3=%myvar3:The default printer is =%
exit /b 
:create_printerportvbs
Rem Creating a vbs to query the computer for the printers installed and their respective ports
echo On Error Resume Next > c:\temp\printerport.vbs
echo. >> c:\temp\printerport.vbs 
echo strComputer = "."  >> c:\temp\printerport.vbs
echo Set objWMIService = GetObject("winmgmts:" _ >> c:\temp\printerport.vbs
echo ^& "{impersonationLevel=impersonate}!\\" _>> c:\temp\printerport.vbs
echo ^& strComputer ^& "\root\cimv2")>> c:\temp\printerport.vbs
echo. >> c:\temp\printerport.vbs
echo Set colItems = objWMIService.ExecQuery("Select * from Win32_Printer")>> c:\temp\printerport.vbs
echo. >> c:\temp\printerport.vbs
echo For Each objItem In colItems>> c:\temp\printerport.vbs
echo ^WScript.Echo objItem.DeviceID ^& "," _>> c:\temp\printerport.vbs
echo ^& objItem.PortName ^& "," _>> c:\temp\printerport.vbs
echo ^& objItem.Default>> c:\temp\printerport.vbs
echo. >> c:\temp\printerport.vbs
echo 'WScript.Echo>> c:\temp\printerport.vbs
echo Next>> c:\temp\printerport.vbs
cscript //nologo c:\temp\printerport.vbs | findstr /v "Microsoft" > output.txt
exit /b 
:change_drivers
Rem Drivers section
echo Changing Drivers:
cd %SystemRoot%\system32
echo Deleting exisiting UPD 5.0 driver if exists
Cscript Prndrvr.vbs -d -m "HP Universal Printing PCL 5 (v5.0)" -v 3 -e "Windows NT x86"
echo Installing fresh UPD 5.0 driver from server
rundll32 printui.dll,PrintUIEntry /ia /m "HP Universal Printing PCL 5 (v5.0)" /f "\\server01\upd5pcl5\hpcu091b.inf" /u
call :sleepy 5
for /f "tokens=1,2 delims=," %%a in (c:\temp\output.txt) do (
echo Deleting printers
Cscript Prnmngr.vbs -d -p "%%a"
call :sleepy 5
echo Adding printers
Cscript prnmngr.vbs -ac -p "%%a" -m "HP Universal Printing PCL 5 (v5.0)" -r "%%b"
echo Re-instating the default printer
Cscript Prnmngr.vbs -t -p "%myvar3%"
)
exit /b 
:sleepy
REM %1 is the number of seconds for the delay, as specified on the command line
> "%Temp%.\sleep.vbs" ECHO WScript.Sleep %~1 * 1000
CSCRIPT //NoLogo "%Temp%.\sleep.vbs"
DEL "%Temp%.\sleep.vbs"
exit /b 
:cleanup
echo Cleaning up
echo y|del c:\temp\output.txt
echo y|del c:\temp\defprn.txt
echo y|del c:\temp\printerport.vbs 
:eof

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:

Select allOpen in new window

 

by: netcmhPosted on 2009-11-05 at 10:45:44ID: 25752531

Mods please close

 

by: ee_autoPosted on 2009-12-29 at 01:19:00ID: 26136528

Question PAQ'd, 500 points refunded, and stored in the solution database.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...