Ok…this one is a little old but its always useful to know how to silently install and configure a printer.
For starting, you should have a look at the command line options for installing a printer.
rundll32 printui.dll,PrintUIEntry /?
Now, using this example you may install a printer.
1. First install the printer by hand and configure it like you want it for final use (except network ports, which I never tested)
2. Use the command rundll32 printui.dll,PrintUIEntry /Ss /n “printer” /a “file.dat” where “printer” is the name of the printer you’ve installed and “file.dat” is the name of the file for saving the printer configuration
3. Now that you have the configuration file you can uninstall the printer and the printer driver from the computer.
4. For installing the printer you need to take a look at the *.inf file for the string you need for installing the printer.
5. On this example I’ve used the *.inf file from a HP LaserJet 2420 printer.
6. If you open it will notice a string that contains the text “HP LaserJet 2420 PCL 5e”. This is the string part that you’ll need for installing the driver that you want.
7. Now that you have the string for installing the print just run something like the following command-line:
wshShell.Run “rundll32 printui.dll,PrintUIEntry /if /b “& aspas & “HP LaserJet 2420″ & aspas & ” /f C:\Temp\HPLaserJet2420\Drivers\hpc24×0b.inf /r ” & aspas & “lpt1:” & aspas & ” /m ” & aspas & “HP LaserJet 2420 PCL 5e” & aspas,7,True
8. On the example above this is a vbscript line, and what you need to know is:
§ “HP Laserjet 2420″ – The name you want your printer to show on Printers & Faxes.
§ “C:\Temp\HPLaserJet2420\Drivers\hpc24×0b.inf” – The path where your *.inf file is.
§ “lpt1:” – The port for the printer.
§ “HP LaserJet 2420 PCL 5e” – The string text that you’ve found before.
9. After this, you’ll notice that the printer will not have the configurations you want, so let’s configure it! Again, run something like this command-line:
wshShell.Run “rundll32 printui.dll,PrintUIEntry /Sr /n “& aspas & “HP LaserJet 2420″ & aspas & ” /a ” & aspas & “C:\Temp\HPLaserJet2420\HPLaserJet2420.dat”
10.On the example above this is again a vbscript line, and again, this is what you need to know:
§ “HP Laserjet 2420″ - The name of your printer like it shows on Printers & Faxes.
§ “C:\Temp\HPLaserJet2420\HPLaserJet2420.dat” – The path for your configurations file that you’ve saved before.
Problems:
This didn’t happened with all drivers I’ve tested but…sometimes when installing the drivers with no user logged in, the drivers just don’t install. So in case of software distribution, like always, you should test this before sending it for a production environment.
Posted by Diogo Sousa
Posted by Diogo Sousa