mac_shinobi Posted May 25, 2010 Posted May 25, 2010 As per this thread - didn't want to hijack it too much and also could use input from the likes of Arthur / Srochford / webman etc http://www.edugeek.net/forums/scripts/56644-installing-hp-colour-laserjet-c3525n-using-inf-files.html There seems to be 3 methods ( correct me if I am wrong ) 1. rundll method to add a printer with relevant switches as per ms kb possibly using the printui.dll 2. using the included vbscripts ( which as per Arthurs comment change directory depending on OS ) 3. Using WMI as per the activxperts website and computerperformance site Printer Port Scripting, Monitor Printer Ports using VBScript Guy's Scripting Ezine 118 - TCP/IP Printing printui Taking the above into consideration I just wanted to know across the board operating system wise ( xp / vista / windows 7 ) what would be the most compatible as in it would work regardless. I was contemplating using the rundll method but then I would require some method of being able to read the inf file that is included in the driver for the printer to be installed which will vary depending on manufacturer and model of printer / copier etc as am not sure which line(s) I will need to read out of the inf file to be able to use the rundll method correctly to get it to work - so any suggestions or help on this would be great. Other then that main point of this question is to find the most compatible method of adding a printer in the background with the least amount of user interaction / involvement.
Arthur Posted May 26, 2010 Posted May 26, 2010 Personally I would choose either method two or three, although the third method does have a slight advantage in that you do not have to depend on any external files (rundll32 or the various VBScripts included with Windows) - not sure if that matters though? Since you cannot create TCP/IP printer ports via printui.dll, you might as well do everything via WMI to keep things simple. I was contemplating using the rundll method but then I would require some method of being able to read the inf file that is included in the driver for the printer to be installed which will vary depending on manufacturer and model of printer / copier etc. All three of the methods listed above would still require you to know the printer(s) model from the INF. Here are some examples... [RICOH] "[b]RICOH Aficio MP C2000 PCL 5c[/b]" = RIC53D,USBPRINT\RICOHAficio_MP_C20000769,LPTENUM\RICOHAficio_MP_C20000769,RICOHAficio_MP_C20000769,RICOHAficio_MP_C2000_769 "[b]RICOH Aficio MP C2500 PCL 5c[/b]" = RIC53D,USBPRINT\RICOHAficio_MP_C25000679,LPTENUM\RICOHAficio_MP_C25000679,RICOHAficio_MP_C25000679,RICOHAficio_MP_C2500_679 "[b]RICOH Aficio MP C3000 PCL 5c[/b]" = RIC53D,USBPRINT\RICOHAficio_MP_C3000FB68,LPTENUM\RICOHAficio_MP_C3000FB68,RICOHAficio_MP_C3000FB68 [DELL] "[b]Dell Laser Printer 5100cn PCL6[/b]"=DLXCRZP,LPTENUM\DellLaser_Printer_51234F "[b]Dell Laser Printer 5100cn PCL6[/b]"=DLXCRZP,USBPRINT\DellLaser_Printer_51234F [strings] HP_Mombi_Driver_Name ="[b]HP LaserJet P2015 Series PCL 6[/b]" [HP] %HP_Mombi_Driver_Name%=LJ_P2015,USBPRINT\Hewlett-PackardHP_LaF552 %HP_Mombi_Driver_Name%=LJ_P2015,USBPRINT\Vid_03f0&Pid_3817 The bit you need to look for is the text shown in bold. When it comes to installing a driver which is for more than one model, you would just specify the name of each model individually.
mac_shinobi Posted May 26, 2010 Author Posted May 26, 2010 Personally I would choose either method two or three, although the third method does have a slight advantage in that you do not have to depend on any external files (rundll32 or the various VBScripts included with Windows) - not sure if that matters though? Since you cannot create TCP/IP printer ports via printui.dll, you might as well do everything via WMI to keep things simple. All three of the methods listed above would still require you to know the printer(s) model from the INF. Here are some examples... [RICOH] "[b]RICOH Aficio MP C2000 PCL 5c[/b]" = RIC53D,USBPRINT\RICOHAficio_MP_C20000769,LPTENUM\RICOHAficio_MP_C20000769,RICOHAficio_MP_C20000769,RICOHAficio_MP_C2000_769 "[b]RICOH Aficio MP C2500 PCL 5c[/b]" = RIC53D,USBPRINT\RICOHAficio_MP_C25000679,LPTENUM\RICOHAficio_MP_C25000679,RICOHAficio_MP_C25000679,RICOHAficio_MP_C2500_679 "[b]RICOH Aficio MP C3000 PCL 5c[/b]" = RIC53D,USBPRINT\RICOHAficio_MP_C3000FB68,LPTENUM\RICOHAficio_MP_C3000FB68,RICOHAficio_MP_C3000FB68 [DELL] "[b]Dell Laser Printer 5100cn PCL6[/b]"=DLXCRZP,LPTENUM\DellLaser_Printer_51234F "[b]Dell Laser Printer 5100cn PCL6[/b]"=DLXCRZP,USBPRINT\DellLaser_Printer_51234F [strings] HP_Mombi_Driver_Name ="[b]HP LaserJet P2015 Series PCL 6[/b]" [HP] %HP_Mombi_Driver_Name%=LJ_P2015,USBPRINT\Hewlett-PackardHP_LaF552 %HP_Mombi_Driver_Name%=LJ_P2015,USBPRINT\Vid_03f0&Pid_3817 The bit you need to look for is the text shown in bold. When it comes to installing a driver which is for more than one model, you would just specify the name of each model individually. How do you read the inf file - is it the same as reading any text file using the File System Object and if so how do I do a search in vbs for just the piece of text highlighted in bold ?
jamesreedersmith Posted May 26, 2010 Posted May 26, 2010 What about client side extensions if you have a server 2008?
mac_shinobi Posted May 26, 2010 Author Posted May 26, 2010 What about client side extensions if you have a server 2008? dont have server 2008 and wanted a hta that would * Add relevant port type ( in this case standard tcp/ip using either LPR or RAW ) * Install driver * Add said model of printer using already added port and driver - I can use a browse dialog window etc for user to select exact directory of driver directory etc.
Arthur Posted May 26, 2010 Posted May 26, 2010 You should be able to work with INF files in the same way as you would an INI file. There is a function called ReadINI that may help on the following website... http://www.robvanderwoude.com/vbstech_files_ini.php However, you can't use this as it is because it returns the value of a key, and not the key itself (which is what you need). If you only have to deal with Ricoh printers/copiers, the model names you need would most likely be listed under the [RICOH] section in the INF. Would Ricoh's universal print driver any good as it could cut down on the number of models you would have to deal with?
mac_shinobi Posted May 26, 2010 Author Posted May 26, 2010 You should be able to work with INF files in the same way as you would an INI file. There is a function called ReadINI that may help on the following website... VBScript Scripting Techniques: Read and write INI files However, you can't use this as it is because it returns the value of a key, and not the key itself (which is what you need). If you only have to deal with Ricoh printers/copiers, the model names you need would most likely be listed under the [RICOH] section in the INF. Would Ricoh's universal print driver any good as it could cut down on the number of models you would have to deal with? No universal is no good and I did come across read ini function but I couldn't figure out how to make that get the model of printer from the ini file as I kept getting null strings returned
Arthur Posted May 26, 2010 Posted May 26, 2010 (edited) I couldn't figure out how to make that get the model of printer from the ini file as I kept getting null strings returned I have just come across another set of INI functions called ClsINI from JSWare which look a bit more useful. Please see the attached file for an example which shows you how to read all of the keys & values from the [RICOH] section of the included INF into an array. If you can find a way to extract the model name(s) from this array then you will be almost there. INI-Example.7z Edited May 27, 2010 by Arthur 1
mac_shinobi Posted May 27, 2010 Author Posted May 27, 2010 I have just come across another set of INI functions called ClsINI from JSWare which look a bit more useful. Please see the attached file for an example which shows you how to read all of the keys & values from the [RICOH] section of the included INF into an array. If you can find a way to extract the model name(s) from this array then you will be almost there. Won't have a chance till later or the weekend but will see how I get on, assuming the ini function / wrapper works I can use the split / replace functions to ascertain the model but am assuming that at least for the ricoh printers / copiers the ini files change ? Will have to look into that
mac_shinobi Posted May 31, 2010 Author Posted May 31, 2010 (edited) I have just come across another set of INI functions called ClsINI from JSWare which look a bit more useful. Please see the attached file for an example which shows you how to read all of the keys & values from the [RICOH] section of the included INF into an array. If you can find a way to extract the model name(s) from this array then you will be almost there. Using the split function to split by quote marks using code as per attached file - the location of the name of printer varies depending on driver and from what I can tell if its a photocopier or a desktop printer ie SPC / SP type machines ( SPC 232 SF ) versus a photocopier ie MPC 3000 RPCS Driver wise they have used variables ie %PRNONE% = "MPC 3000 PCL5e" which is under the strings section where as under the Ricoh section it just literally refers to %PRNONE% The attached vbs works fine if its a PCL 5 driver, not tested it on PCL 6 though Rename the attached txt file to a hta ( file extension hta that is ) Just as a side note I have not added the code from ClsINI vbs file into the hta as of yet as still wanna work on the other driver type inf files first Also any chance someone could zip up the windows 7 vbscript files so I can look at those and how windows 7 does it.Fianl ClsINI.vbscurrent rev - add printer.txt Edited May 31, 2010 by mac_shinobi
Arthur Posted May 31, 2010 Posted May 31, 2010 HTA is looking good. Not quite sure how you can deal with the variables though. Any chance someone could zip up the windows 7 vbscript files so I can look at those and how windows 7 does it. Attached.PrintingAdminScripts.7z 1
mac_shinobi Posted May 31, 2010 Author Posted May 31, 2010 (edited) Np will look at the different drivers and see if I can establish if it's the driver type ie pcl vs rpcs vs post script etc and then it's just a case of establishing what code to change to make it read the different sections depending on the driver being used Update - added the latest revision of my hta which works on windows xp, not sure about windows 7 due to WMI code etc. It has to be in the exact same directory where the inf file is which with Ricoh drivers is in the same directory as all the files including the inf file, dll files etc oh yeah and so far it only works with PCL 5 and PCL 6 drivers. Thoughts please Final rev 1.20 - add printer .txt Edited June 1, 2010 by mac_shinobi
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now