續:可適應印表機部署(1)
詳述:
印表機部署的管理主要是基於檔案的,下面將要分別介紹使用電腦分組、印表機列表和印表機配置資訊來描述企業內部管理狀態,理解這些檔案的使用定義,是決定成功使用本指令碼的關鍵一步。
管理電腦分組
在現實中,電腦的功能是可以用分組的方式來描述的,就如同在LDAP中管理電腦和使用者一樣,具有相同功能/用途的電腦,或者相同管理背景的使用者被分在同一組一樣。同樣,印表機的管理也是用分組的方式,一個印表機分組中的電腦,都具有相同印表機的配置,不同的列印配置的電腦被分在不同的組。
指令碼使用預設的檔案名稱Groups.ini來描述電腦分組,檔案的格式很簡單,一行代表一個電腦的分組定義,前面是分組的名稱,後面是電腦名稱,他們使用ASCII碼逗號”,”分開;#符號使用者注釋一行,它必須在每行的開始;空行被忽略。
一個Groups.ini檔案的舉例:
# --------------------------------------------------# File Name: Groups.ini# Porpose: This is the group list file.# Please modifythis file every time computer group# is changed ornew computer arrived or old computer# isdicommissioned.# Format:# Group andcomputername separated by comma ",".# Created: Aug 20, 2008 Tony Liu# --------------------------------------------------Office, W857-1283Office, W999-002Office, W999-003Office, W999-004Lib, W218-732Mobile, W218-642Mobile, w218-645
管理印表機列表
前面說過,每一組電腦安裝有相同的印表機,我們使用一個檔案來定義一個組所要安裝的所有印表機。上面定義了每個電腦的分組,每個分組有個組名,我們就使用每個組的組名作為檔案名稱,比如上面有Office,Lib,和Mobile三個分組,我們為每個分組定義一個印表機列表。
印表機列表更簡單,每個印表機名稱佔一行;第一個印表機是預設印表機;#符號使用者注釋一行,它必須在每行的開始;空行被忽略。
下面是一個Lib分組的例子:
#-----------------------------------------# Lib group printer list.#-----------------------------------------P218LIB3P218LIB2(Color)P218BAS1P218WRM1
下面是一個Office分組的例子:
#-----------------------------------------# Office group printer list.#-----------------------------------------P218OFF1P218LIB2(Color)P218LIB3
通過上面兩個部分的介紹,我們有了一個印表機管理方法的輪廓,把具有相同印表機配置的電腦分組,列表存放在Groups.ini檔案中,然後為每個分組分別建立印表機列表檔案,裡面列出該組所須安裝的印表機。
其實,也可以使用LDAP服務中的Computer的Location資訊來對每個電腦進行分組,把分組名稱填入Location裡面。由於每個系統的實施不同,LDAP的描述不同,指令碼中有該函數,不過需要個人根據自己的網路設定環境進行修改LDAP字串。
配置印表機配置資訊
終於來到這裡了,上面說了分組啊,印表機列表啊伍的,印表機的具體描述呢?比如,印表機驅動程式,印表機IP地址等等。
每個印表機的具體描述,是在印表機配置資訊PrinterConfig.ini檔案中定義的。每行定義一個印表機,每行由預定義順序的欄位組成,每個欄位之間使用ASCII碼的逗號”,”分隔,可選欄位可以為空白,但不能省略分隔字元,每個欄位的前後空格和Tab被忽略;#符號使用者注釋一行,它必須在每行的開始;空行被忽略。
每個欄位順序定義為如下:
1. 系統平台定義:x32是定義本印表機配置是為32位系統使用的;x64是為64位系統使用的。
2. 印表機名稱:印表機名,這個名稱就是在印表機列表檔案中所羅列的印表機名對應。
3. IP地址:也就是該印表機的IP地址。如果使用DNS名稱也可以。
4. INF檔案:這個定義印表機驅動程式的位置和它所使用的印表機描述inf檔案。
5. 印表機型號:其實就是該印表機的驅動名稱。在前面的“準備”一節中有介紹如何找到它。
6. 位置:為了方便使用者找到這個印表機,在每個安裝的印表機中可以定義“位置”資訊,這是一個可選欄位。
7. 注釋:這也是一個可選欄位,管理員可以添上附加的注釋,比如彩色列印,不要使用雙面等等。
8. 禁止訪問的使用者組:這個欄位可選,用來限制一個組的使用者訪問該印表機。(這個功能將來可以被擴充為更多和靈活的文法,以適應更複雜的環境。)
關於系統平台定義這個欄位,管理員完全可以通過定義不同的印表機名來區別64位還是32位系統,問題是,需要不太一樣的印表機名,而且要手動區分。而有了這個欄位定義,就可以為32位或者64位系統,定義使用相同的印表機名,方便管理和使用者使用。記住,對每個印表機都要有32位和64位的列印驅動定義。
下面是一個例子:
#--------------------------------------------------------------------------------------------# File Name: PrinterConfig.ini# Purpose:# This is theprinters Configuration file, Please modify this file whenever a printer is# changed, suchlike, location moved, model changed, decommissioned, IP changed and etc.## Format:# Each linedefines only one printer information. It includes:# PrinterName,IP,DriverInfFile,PrinterModel,Location, Comment, DenyGroup# Each field isseparated by a comma ",".# The maximumnumber of printers is 500. # Linesstarting with # are comments.## Specificationof each field:# OSPlatform: “x32” is for x86 system, “x64” for x64 system.# PrinterName:# Theprinter name shows in the Printers and Faxes list in XP.# IP:# Avalid IP address. if IP=0.0.0.0 then use PrinterName as IP, the PrinterName# mustbe defined in DNS.# Driver'sInf File:# Theprinter INF file UNC name, it must be in the driver path.# Ifthis field="" then system will not install any driver, it assumesdriver# whichis defined in DriverName field is system defned model.# PrinterModel:# Theprinter driver name for this printer.# Locations:# Optional, it shows the printer location in the printer Property'sLocation field.# Comment:# Optional, it shows the printer comment in the printer Property'sComments field.# DenyGroup:# Optional, if this printer won't be accessed by studentput the studentsgroup# SID(not group name) here, otherwise leave it blank.# Usepsgetsid utility to fetch a user group SID, for example:# PsGetSid cbeedu\110-students_G## Created: Aug 20, 2008 Tony Liu# Modified:# Aug 28, 2008Tony Liu: Added IP=0.0.0.0# Dec 04, 2010Tony Liu: Reorganizing comments.# dec 07, 2010Tony Liu: Redefined printer information fields.# dec 16, 2010Tony Liu: Added DenyGroup option.# May 31, 2012Tony Liu: Support OS Platform#--------------------------------------------------------------------------------------------# ---------------------x32----------------------------x32, P374OFF2, 10.23.130.22, .\Driver\HPUPDPCL6_x86\hpcu118c.inf, HPUniversal Printing PCL 6, Main Office, For Office Staff, S-1-5-21-73586283-606747145-725345543-105551x32, P374CPY1, 10.23.130.13, .\Driver\KyoceraPCL6_x86\OEMsetup.inf,Kyocera Classic Universaldriver PCL6, Workroom, Kyocera MFP,x32, P374RM1, 10.23.130.11,.\Driver\HPUPDPCL6_x86\hpcu118c.inf, HP Universal Printing PCL 6, room 1, ForAll students and staff,x32, P374UP1, 10.23.130.21,.\Driver\HPUPDPCL6_x86\hpcu118c.inf, HP Universal Printing PCL 6, Upstairs copyroom, For All students and staff,x32, P374OFF3, 10.23.130.24,.\Driver\HPUPDPCL6_x86\hpcu118c.inf, HP Universal Printing PCL 6, Main Office,For All students and staff, # ---------------------x64----------------------------x64, P374OFF2, 10.23.130.22, .\Driver.x64\HPUPDPCL6_x64\hpcu118u.inf, HPUniversal Printing PCL 6, Main Office, For Office Staff, S-1-5-21-73586283-606747145-725345543-105551x64, P374CPY1, 10.23.130.13, .\Driver.64\KyoceraPLC6_x64\OEMsetup.inf,Kyocera Classic Universaldriver PCL6, Workroom, Kyocera MFP,x64, P374RM1, 10.23.130.11,.\Driver.x64\HPUPDPCL6_x64\hpcu118u.inf, HP Universal Printing PCL 6, room 1,For All students and staff,x64, P374UP1, 10.23.130.21,.\Driver.x64\HPUPDPCL6_x64\hpcu118u.inf, HP Universal Printing PCL 6, Upstairscopy room, For All students and staff,x64, P374OFF3, 10.23.130.24,.\Driver.x64\HPUPDPCL6_x64\hpcu118u.inf, HP Universal Printing PCL 6, MainOffice, For All students and staff,
分公司管理
在運行該指令碼的時候,可以定義Location,也就是說,每個分公司可以有各自的相同名稱的印表機,相同名稱的分組或者電腦名,這個Location資訊被用來添加到所有的上述控制檔案的前面,比如代號為310的分公司的所有控制檔案都以310_開頭,也就是310_PrinterConfig.ini,310_Groups.ini,
310_Office.txt, 310_Mobile.txt等等,這樣管理員可以輕鬆地集中管理不同分公司。
命令列
基本的命令列是:
Cscript APD.vbs options
其中Options可以是:
/l code: 定義分公司代碼
/q: 安靜模式,不輸出任何的運行資訊
/s: 在完成後刪除自身
/d: 刪除所有的TCP/IP印表機,適合於重新部署。
把VBScript指令檔,以及相關的所有檔案都放在一個網際網路共用檔案夾中,
我的配置是這樣的:所有的32位驅動程式放在Driver子檔案夾中,64位驅動程式放在Driver.x64子檔案夾中,其他檔案和指令碼本身都放在這個檔案夾中。
命令列的舉例:
cscript SetupIPPrinter.vbs /l218 /q /d或cscript SetupIPPrinter.vbs /?
其它:
兩個輔助的程式,subinacl.exe用來設定印表機的存取權限,PsGetsid.exe用來獲得一個使用者/使用者組在LDAP服務中的SID。
原始碼:
參見Google Code: http://code.google.com/p/adaptable-printer-deployment/