按:这个脚本是本人写的基于我现在工作的系统网络环境所做的,主要用意是:在一个非Windows服务器管理的网络环境中,提供一种方便的工具,来安装本地的TCP/IP打印机,以方便管理员对打印机的管理。他可以根据计算机的分组信息(分组可以是根据办公室位置来区分,因为打印机都是于位置和权限有关的)以及权限,来安装打印机,这样不同的人员在本台电脑上登录,可以存取到最近的可以打印的打印机,而不是远在其它地方的打印机。
下面是我编写的英文版本的使用说明初稿,还没有在我公司内部发布,先放在我的blog里面。等我有时间再来翻译过来。
Name: SetupIPPrinter (set up Local TCP/IP printer)
Created: May 14, 2010
Updated: Dec 12, 2010
Description:
This program set up TCP/IP printer on a local PC for all users who logged in.
It is used on the following 3 situation but not limited:
School has no server.
School has a Mac server.
School has a PC server, but some AD user groups have to use local TCP/IP printer.
Introduction:
In a PC server school, student printing is managed on server and teachers can put network printer connection easily too. In a none-PC server school, school tech may have to set up TCP/IP printer on each PC for teachers and/or students manually for now. Doing this manual setup is a time consuming task, especially for a number of computers. The purpose of this program is to fill the gap to provide a simple and easy way for school tech to set up printer on PCs.
On a PC server, we manage menus$ share and put a printer list file in "location" folders which is defined in computers' Location field on AD. This program does the similar way and provides more options.
Printer Configuration:
Setup a local printer is different from a network printer connection, it asks for
model, driver, TCP/IP port, and others. So we must define each printer configuration first. All printer configuration information is stored in a file called PrinterConfig.ini file.
Note : if you put /c option in command line, this file name will be changed, for example, /c 212, the file name will be 212_PrinterConfig.ini
Define a Printer Configuration file:
This file is a standard DOS text file. Each line defines one and only one printer. Each line has the following format:
Permission, PrinterName, IP, DriverInfFile, PrinterModel, Location, Comment
A comma separates each field. The maximum number of printers is 500.
Lines starting with # are comments. Spaces before and behind each field will be ignored.
Specification of each field:
Permission : either A or S
1. A = All users can print
2. S = Staff only can print
PrinterName :
The printer name shows in the Printers and Faxes list in XP.
IP :
A valid IP address or the Printer name which is defined in DNS.
Driver's Inf File :
The UNC name of a printer driver INF file, it must be in the driver path.
If this field="", then system will not install any driver, it assumes
The driver exists in system printer cab.
Printer Model :
The printer model driver name. This name is listed on printer driver list.
Locations :
Optional, the printer location in the printer Property's Location field.
Comment :
Optional, the printer comment in the printer Property's Comments field.
For example:
A, P241LAB1, 10.23.66.2, ./HPUPD/hpcu109c.inf, HP Universal Printing PCL 6, Computer Lab, For All students and Staff
It defines a "P241LAB1" printer, whose IP address is 10.23.66.2, the printer driver INF file is in a subfolder "HPUPD", of current folder, file name is hpcu109c.inf, the printer model driver name is "HP Universal Printing PCL 6", the location is "Computer Lab", the comment is "For All students and Staff", and all users(staff and students) can print to it.
Location List file:
What printers are set up on a computer is determined by it’s location. A computer’s location can be defined in AD, or in a Location List file. A location List file is a standard DOS text file and each line defines a computer’s location. The file name is Locations.ini .
Note : if you put /c option in command line, this file name will be changed, for example, /c 212, the file name will be 212_Locations.ini
The format of each line is:
Location, ComputerName
A comma separates each field. Lines starting with # are comments. Spaces before and behind each field will be ignored.
Location:
The location name. this name is a location file name.
ComputerName:
The computer name.
For example:
Office, W999-001
Library, W999-004
Lab, w999-201
What it does?
Location Printer List file:
Each location of a computer can have a list of printers and a default printer.
This file’s format is simple. It lists all the printers that this location’s computers can access. The file name is the location name, for example, location Library has a location printer list file named “Library.txt”.
Each printer occupies one line. The printer name must be same as the one in Printer Configuration file. The first printer on the list is the default printer. Spaces before and behind will be ignored.
There’s a special Location List file, Default.txt . All the computers which doesn’t have a location defined, will get printer list from this file.
Example of Location Printer list file:
P212OFF1
P212LIB1
P212LAB1
Run it, SetupIPPrinter.vbs
How it works?
It gets computer name, find the computer’s location from Locations.ini file, for example, lab; and make the location name as file name to open the location printer list file, lab.txt, and read the printer list, for each printer, read printer configuration PrinterConfig.ini , and then set it up.
Usage:
cscript PrinterSetup.vbs [options….]
/c: define school code, this code is used for configuration files name only.
/l [0|1|2]: log message level.
Log Level:
0: only system info
1: Error only
2: Error and warning messages
3: All messages
/d: Delete all TCP/IP ports and printers first.
/p: the full path of configuration files. Default=the same as script’s.
/?: online help.
Please put SetACL.exe file with this script.
Put all together:
Best practice:
1. Collect all school computers name with locations.
2. Collect all printers and what locations computer will printer to it.
3. Define a location name for each group of computers which have same printers
to print.
4. Create printer configuration file, named "PrinterConfig.ini ", and add printers.
5. Update computer location in AD, or add all computers location to "Locations.ini " file, and remember which method you chose. File ot AD?
6. Decide where to save these configuration files, ie. *.txt and *.ini files:
On school server share folder? write down the share folder's URL.
On a folder on each location machine? write down the location.
Save these files to the destination folder.
7. Test it with debug log level to 2 or 3. Check the info messages. Go back to make changes if program reports warnings or errors.
8. Set log level to 0 or 1 when you decide to run program in product environment.
9. Deploy it in WDS or run it on a computer.
A complete example:
PrinterConfig.ini file:
S, P999CPY1, 10.45.66.9, ./HPUPD/hpcu109c.inf, HP Universal Printing PCL 6, WorkRoom near Office, For All Staff only
S, P999MFP1, 10.45.66.10, ./Ricoh/oemsetup.inf, PCL6 Driver for Universal Print, Copier Room, For All Staff only
S, P999OFF1, 10.45.66.2, ./HPUPD/hpcu109c.inf, HP Universal Printing PCL 6, WorkRoom near Office, For All Staff only
A, P999LAB1, 10.45.66.5, ./HPUPD/hpcu109c.inf, HP Universal Printing PCL 6, WorkRoom near Office, For All Staff only
Locations.ini file:
Office, W999-001
Office, W999-002
Lab, w999-101
Room01, W999-501
Lib, w999-690
Office.txt
P99OFF1
P999CPY1
P999MFP1
Default.txt
P999LAB1
P999MFP1
P999CPY1
Put all these files in a folder, c:/IPPrinter.
Run the program command line:
cscript c:/IPPrinter/setupIPPrinter.vbs /l 3 /d