+ Post New Thread
Results 1 to 15 of 15
Scripts Thread, hta - add printer in Coding and Web Development; As per this thread - didn't want to hijack it too much and also could use input from the likes ...
  1. #1

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,754
    Thank Post
    3,265
    Thanked 1,052 Times in 973 Posts
    Rep Power
    365

    hta - add printer

    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

    Installing HP Colour Laserjet c3525n using inf files

    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.

  2. #2


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    8,866
    Thank Post
    226
    Thanked 2,665 Times in 1,964 Posts
    Rep Power
    785
    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.

    Quote Originally Posted by mac_shinobi View Post
    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...

    Code:
    [RICOH]
    "RICOH Aficio MP C2000 PCL 5c" = RIC53D,USBPRINT\RICOHAficio_MP_C20000769,LPTENUM\RICOHAficio_MP_C20000769,RICOHAficio_MP_C20000769,RICOHAficio_MP_C2000_769
    "RICOH Aficio MP C2500 PCL 5c" = RIC53D,USBPRINT\RICOHAficio_MP_C25000679,LPTENUM\RICOHAficio_MP_C25000679,RICOHAficio_MP_C25000679,RICOHAficio_MP_C2500_679
    "RICOH Aficio MP C3000 PCL 5c" = RIC53D,USBPRINT\RICOHAficio_MP_C3000FB68,LPTENUM\RICOHAficio_MP_C3000FB68,RICOHAficio_MP_C3000FB68
    Code:
    [DELL]
    "Dell Laser Printer 5100cn PCL6"=DLXCRZP,LPTENUM\DellLaser_Printer_51234F
    "Dell Laser Printer 5100cn PCL6"=DLXCRZP,USBPRINT\DellLaser_Printer_51234F
    Code:
    [Strings]
    HP_Mombi_Driver_Name ="HP LaserJet P2015 Series PCL 6"
    
    [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.

  3. #3

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,754
    Thank Post
    3,265
    Thanked 1,052 Times in 973 Posts
    Rep Power
    365
    Quote Originally Posted by Arthur View Post
    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...

    Code:
    [RICOH]
    "RICOH Aficio MP C2000 PCL 5c" = RIC53D,USBPRINT\RICOHAficio_MP_C20000769,LPTENUM\RICOHAficio_MP_C20000769,RICOHAficio_MP_C20000769,RICOHAficio_MP_C2000_769
    "RICOH Aficio MP C2500 PCL 5c" = RIC53D,USBPRINT\RICOHAficio_MP_C25000679,LPTENUM\RICOHAficio_MP_C25000679,RICOHAficio_MP_C25000679,RICOHAficio_MP_C2500_679
    "RICOH Aficio MP C3000 PCL 5c" = RIC53D,USBPRINT\RICOHAficio_MP_C3000FB68,LPTENUM\RICOHAficio_MP_C3000FB68,RICOHAficio_MP_C3000FB68
    Code:
    [DELL]
    "Dell Laser Printer 5100cn PCL6"=DLXCRZP,LPTENUM\DellLaser_Printer_51234F
    "Dell Laser Printer 5100cn PCL6"=DLXCRZP,USBPRINT\DellLaser_Printer_51234F
    Code:
    [Strings]
    HP_Mombi_Driver_Name ="HP LaserJet P2015 Series PCL 6"
    
    [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 ?

  4. #4
    jamesreedersmith's Avatar
    Join Date
    Sep 2009
    Location
    Ruskington
    Posts
    1,158
    Thank Post
    78
    Thanked 253 Times in 227 Posts
    Rep Power
    76
    What about client side extensions if you have a server 2008?

  5. #5

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,754
    Thank Post
    3,265
    Thanked 1,052 Times in 973 Posts
    Rep Power
    365
    Quote Originally Posted by jamesreedersmith View Post
    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.

  6. #6


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    8,866
    Thank Post
    226
    Thanked 2,665 Times in 1,964 Posts
    Rep Power
    785
    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?

  7. #7


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    8,866
    Thank Post
    226
    Thanked 2,665 Times in 1,964 Posts
    Rep Power
    785
    By the way, have you seen this HTA?

  8. Thanks to Arthur from:

    mac_shinobi (27th May 2010)

  9. #8

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,754
    Thank Post
    3,265
    Thanked 1,052 Times in 973 Posts
    Rep Power
    365
    Quote Originally Posted by Arthur View Post
    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

  10. #9


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    8,866
    Thank Post
    226
    Thanked 2,665 Times in 1,964 Posts
    Rep Power
    785
    Quote Originally Posted by mac_shinobi View Post
    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.
    Attached Files Attached Files
    Last edited by Arthur; 27th May 2010 at 01:53 AM.

  11. Thanks to Arthur from:

    mac_shinobi (27th May 2010)

  12. #10

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,754
    Thank Post
    3,265
    Thanked 1,052 Times in 973 Posts
    Rep Power
    365
    Quote Originally Posted by Arthur View Post
    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

  13. #11

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,754
    Thank Post
    3,265
    Thanked 1,052 Times in 973 Posts
    Rep Power
    365
    Quote Originally Posted by Arthur View Post
    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.
    Attached Files Attached Files
    Last edited by mac_shinobi; 31st May 2010 at 04:56 PM.

  14. #12


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    8,866
    Thank Post
    226
    Thanked 2,665 Times in 1,964 Posts
    Rep Power
    785
    HTA is looking good. Not quite sure how you can deal with the variables though.

    Quote Originally Posted by mac_shinobi View Post
    Any chance someone could zip up the windows 7 vbscript files so I can look at those and how windows 7 does it.
    Attached.
    Attached Files Attached Files

  15. Thanks to Arthur from:

    mac_shinobi (31st May 2010)

  16. #13

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,754
    Thank Post
    3,265
    Thanked 1,052 Times in 973 Posts
    Rep Power
    365
    Which variables?

  17. #14


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    8,866
    Thank Post
    226
    Thanked 2,665 Times in 1,964 Posts
    Rep Power
    785
    The ones in the [STRINGS] section?

  18. #15

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,754
    Thank Post
    3,265
    Thanked 1,052 Times in 973 Posts
    Rep Power
    365
    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
    Attached Files Attached Files
    Last edited by mac_shinobi; 1st June 2010 at 08:03 PM.

SHARE:
+ Post New Thread

Similar Threads

  1. Add a shared printer for all users in XP
    By R1ch in forum Windows
    Replies: 7
    Last Post: 11th November 2010, 07:09 PM
  2. Add printer driver without *.INF file to server 2003
    By shafeek in forum Windows Server 2000/2003
    Replies: 2
    Last Post: 29th March 2010, 01:03 PM
  3. Disable Add Printer on 10.6 or WGM
    By 10101010 in forum Mac
    Replies: 1
    Last Post: 18th February 2010, 06:37 PM
  4. hta to update / add to specific cell
    By mac_shinobi in forum Scripts
    Replies: 1
    Last Post: 12th February 2010, 05:53 PM
  5. Add printer script not workling
    By mark in forum Windows
    Replies: 6
    Last Post: 15th September 2005, 10:07 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •