Pour différentes imprimantes à installer, j’en avais un peu marre de les installer à la main (je suis flemmard, mais si nous avons choisi l’informatique c’est bien pour se faciliter la vie non ?), j’ai donc décider de creuser l’installation automatique par .bat (note pour plus tard : les GPO c’est bien aussi ^^).
Dans ce cas de figure nous n’avons bien sur pas de serveur de spool d’impression, car du coup cela aurait été plus simple (pour les pilotes) ! Ici les machines tapent directement sur l’imprimante.
- – Première chose à faire : récupérer tous les pilotes constructeur de vos imprimantes, pour tous les os (le mieux c’est de les tester avant !),
- – Deuxième chose : stocker vos pilotes sur le réseau, pour qu’ils soient disponible sur les ordinateurs sur lequel vous allez lancer votre .bat (perso nous avons monté un DFS au boulot pour les sites distants ou nous y stockons : drivers, appli, mises à jour de logiciel),
Le premier .bat consiste à déterminer la version de l’O.S. et son architecture pour lui donner le bon pilote à récupérer (ce fichier se nomme detectos.bat) :
@ECHO OFF
IF (%PROCESSOR_ARCHITECTURE%)==(AMD64) (GOTO 64−Bit) ELSE (GOTO 32−Bit)
:32−Bit
set ARCHITECTURE=32
set FPSA=System32
goto check_os
:64−Bit
set ARCHITECTURE=64
set FPSA=SysWOW64
goto check_os
:check_os
REM Check Windows Version
ver | findstr /i "5\.0\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_2000
ver | findstr /i "5\.1\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_XP
ver | findstr /i "5\.2\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_2003
ver | findstr /i "6\.0\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_Vista
ver | findstr /i "6\.1\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_Win7
goto warn_and_exit
:ver_Win7
:Run Windows 7 specific commands here
REM echo OS Version: Windows 7 (debug line)
set FPS=%windir%\%FPSA%\Printing_Admin_Scripts\fr−FR\
goto end
:ver_Vista
:Run Windows Vista specific commands here
REM echo OS Version: Windows Vista (debug line)
set FPS=%windir%\%FPSA%\Printing_Admin_Scripts\fr−FR\
goto end
:ver_2003
:Run Windows Server 2003 specific commands here
REM echo OS Version: Windows Server 2003 (debug line)
set FPS=%windir%\%FPSA%\
goto end
:ver_XP
:Run Windows XP specific commands here
REM echo OS Version: Windows XP (debug line)
set FPS=%windir%\%FPSA%\
goto end
:ver_2000
:Run Windows 2000 specific commands here
REM echo OS Version: Windows 2000 (debug line)
set FPS=%windir%\%FPSA%\
goto end
:warn_and_exit
echo Machine OS cannot be determined.
:end
Ensuite, il nous faut construire un fichier par imprimante, en voici un (après il suffit de changer certaine variable (je vous ai prévenu je suis flemmard !), ici les variables à changer sont (le nom du fichier bat ici c’est le nom de l’imprimante TO3520_DG.bat) :
- PORT_IP : l’ip de l’imprimante
- PRINTER_NAME : le nom de l’imprimante
- FAX_NAME : le nom de l’imprimante + FAX
- GNRL_FOLDER : le dossier du pilote
Prompt $H
cls
@echo OFF
call \\monserveur\informatique\materiel\imprimante\scripts\detectos.bat
set PORT_IP=192.168.0.220
set PRINTER_NAME=TO3520<!−−DVFMTSC−−> DG
set FAX_NAME=%PRINTER_NAME% FAX
set GNRL_FOLDER=\\monserveur\informatique\materiel\imprimante\toshiba\estudio\3520c\
@echo ................................
@echo INSTALLATION D UN PORT TCP/IP
@echo
@echo ................................
@echo IP : %PORT_IP%, Type RAW, et port réseau : 9100 (Toshiba)
cscript %FPS%prnport.vbs −a −r IP_%PORT_IP% −h %PORT_IP% −o raw −n 9100
IF (%PROCESSOR_ARCHITECTURE%)==(AMD64) (GOTO 64−Bit) ELSE (GOTO 32−Bit)
:64−Bit
@echo .............................
@echo INSTALLATION D UNE IMPRIMANTE TOSHIBA ESTUDIO 3520C
@echo x64
@echo .............................
@echo FAX
rundll32 printui.dll, PrintUIEntry /if /z /b "%FAX_NAME%" /f "%GNRL_FOLDER%x64\Drivers64bits_CD3.02_es4520c\Drivers64bits_CD3.02_es4520c\FAX\FRE\eS4cfx6.inf" /r "IP_%PORT_IP%" /m "TOSHIBA e−STUDIO Series Fax"
@echo IMPRIMANTE
rundll32 printui.dll, PrintUIEntry /if /z /b "%PRINTER_NAME%" /f "%GNRL_FOLDER%x64\Drivers64bits_CD3.02_es4520c\Drivers64bits_CD3.02_es4520c\PCL6\FRE\eS4ex6.inf" /r "IP_%PORT_IP%" /m "TOSHIBA e−STUDIO4520CSeriesPCL6"
goto end
:32−Bit
@echo .............................
@echo INSTALLATION D UNE IMPRIMANTE TOSHIBA ESTUDIO 3520c
@echo x86
@echo .............................
@echo FAX
rundll32 printui.dll, PrintUIEntry /if /z /b "%FAX_NAME%" /f "%GNRL_FOLDER%x86\Drivers32bits_CD3.02_es4520c\Drivers32bits_CD3.02_es4520c\FAX\FRE\eS4cfx2K.inf" /r "IP_%PORT_IP%" /m "TOSHIBA e−STUDIO Series Fax"
@echo IMPRIMANTE
rundll32 printui.dll, PrintUIEntry /if /z /b "%PRINTER_NAME%" /f "%GNRL_FOLDER%x86\Drivers32bits_CD3.02_es4520c\Drivers32bits_CD3.02_es4520c\PCL6\FRE\eS4ex2.inf" /r "IP_%PORT_IP%" /m "TOSHIBA e−STUDIO4520CSeriesPCL6"
goto end
:end
Voici comment cela ce passe pour le dernier script :
- Il appel le fichier detectos.bat
- Il créer le port TCP IP pour l’imprimante (vérifier si raw ou pas pour votre imprimante)
- Suivant le retour de detectos.bat il balance à la ligne pour la version x86 (32) ou x64
- Le paragraphe ECHO FAX installe le pilote fax, attention là il faut trouver le fichier inf de pilote du fax et le renseigner (%GNRL_FOLDER%x86\Drivers32bits_CD3.02_es4520c\Drivers32bits_CD3.02_es4520c\FAX\FRE\eS4cfx2K.inf)
Ci dessous pour les plus feignasses d’entre vous sans la partie fax :
Prompt $H
cls
@echo OFF
call \\monserveur\informatique\materiel\imprimante\scripts\DetectOs.bat
set PORT_IP=192.168.0.220
set PRINTER_NAME=TO3520 DG
set GNRL_FOLDER=\\monserveur\informatique\materiel\imprimante\toshiba\estudio\3520c\
@echo ................................
@echo INSTALLATION D UN PORT TCP/IP
@echo
@echo ................................
@echo IP : %PORT_IP%, Type RAW, et port réseau : 9100 (Toshiba)
cscript %FPS%prnport.vbs -a -r IP_%PORT_IP% -h %PORT_IP% -o raw -n 9100
IF (%PROCESSOR_ARCHITECTURE%)==(AMD64) (GOTO 64-Bit) ELSE (GOTO 32-Bit)
:64-Bit
@echo .............................
@echo INSTALLATION D UNE IMPRIMANTE TOSHIBA ESTUDIO 3520C
@echo x64
@echo .............................
@echo IMPRIMANTE
rundll32 printui.dll, PrintUIEntry /if /z /b "%PRINTER_NAME%" /f "%GNRL_FOLDER%x64\Drivers64bits_CD3.02_es4520c\Drivers64bits_CD3.02_es4520c\PCL6\FRE\eS4ex6.inf" /r "IP_%PORT_IP%" /m "TOSHIBA e-STUDIO4520CSeriesPCL6"
goto end
:32-Bit
@echo .............................
@echo INSTALLATION D UNE IMPRIMANTE TOSHIBA ESTUDIO 3520c
@echo x86
@echo .............................
@echo IMPRIMANTE
rundll32 printui.dll, PrintUIEntry /if /z /b "%PRINTER_NAME%" /f "%GNRL_FOLDER%x86\Drivers32bits_CD3.02_es4520c\Drivers32bits_CD3.02_es4520c\PCL6\FRE\eS4ex2.inf" /r "IP_%PORT_IP%" /m "TOSHIBA e-STUDIO4520CSeriesPCL6"
goto end
:end
Enjoy !