2016年12月3日 星期六

利用 BAT 檔,安裝印表機 (以 RICOH MP 2501 PCL 6 為例)

@echo off

IF NOT EXIST "C:\gpo_log\" (
    mkdir "C:\gpo_log\"
    )

IF NOT EXIST "C:\gpo_log\PrinterInstall.log" (
    echo Remove "RICOH MP 2501 PCL 6" Printer: %date:~0,4%%date:~5,2%%date:~8,2% %TIME:~0,5% >> C:\gpo_log\PrinterInstall.log

    rem 避免因 LOG檔 被刪除,而造成重覆安裝印表機,先執行一次刪除動作
    rem 移除印表機裝置
    rundll32 printui.dll,PrintUIEntry /q /dl /n "RICOH MP 2501 PCL 6"

    rem 移除印表機驅動程式,如不想每次重新安裝驅動程式,可以註解不移除
    rundll32 printui.dll,PrintUIEntry /q /dd /m "RICOH MP 2501 PCL 6"

    rem 開始安裝印表機程序
    echo Start install "RICOH MP 2501 PCL 6" Printer: %date:~0,4%%date:~5,2%%date:~8,2% %TIME:~0,5% >> C:\gpo_log\PrinterInstall.log
    cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-TW\Prnport.vbs -a -r IP_192.168.1.5 -h 192.168.1.5 -o raw -n 9100
    rundll32 printui.dll,PrintUIEntry /ia /m "RICOH MP 2501 PCL 6" /f "\\vmsynology\Driver\Printers\RICOH MP2501SP PCL 6\disk1\OEMSETUP.INF"
    rundll32 printui.dll,PrintUIEntry /u /if /b "RICOH MP 2501 PCL 6" /f "\\vmsynology\Driver\Printers\RICOH MP2501SP PCL 6\disk1\OEMSETUP.INF" /r "IP_192.168.1.5" /m "RICOH MP 2501 PCL 6"
    GOTO END
    ) ELSE (GOTO NonInstall)
   
:END
echo Finish install Printer: %date:~0,4%%date:~5,2%%date:~8,2% %TIME:~0,5% >> C:\gpo_log\PrinterInstall.log
exit 0

:NonInstall
echo The printer is installed: %date:~0,4%%date:~5,2%%date:~8,2% %TIME:~0,5% >> C:\gpo_log\PrinterInstall.log
exit 0

沒有留言:

張貼留言

Office 365修改單一使用者的OneDrive儲存空間

1.       下載、安裝 SharePoint Online 套件 https://www.microsoft.com/zh-tw/download/details.aspx?id=35588 2.       輸入連線指令 $adminUPN=&q...