Windows: 根据分组的本地TCP/IP打印机的安装(1)

来源:互联网 发布:csol发生网络问题 编辑:程序博客网 时间:2024/04/28 07:16

 

按:这个脚本是本人写的基于我现在工作的系统网络环境所做的,主要用意是:在一个非Windows服务器管理的网络环境中,提供一种方便的工具,来安装本地的TCP/IP打印机,以方便管理员对打印机的管理。他可以根据计算机的分组信息(分组可以是根据办公室位置来区分,因为打印机都是于位置和权限有关的)以及权限,来安装打印机,这样不同的人员在本台电脑上登录,可以存取到最近的可以打印的打印机,而不是远在其它地方的打印机。

下面是我编写的英文版本的使用说明初稿,还没有在我公司内部发布,先放在我的blog里面。等我有时间再来翻译过来。

 

Name: SetupIPPrinter (set up LocalTCP/IP printer)

 

Created: May 14, 2010

Updated: Dec 12, 2010

Description:

    This program setup TCP/IP printer on a local PC for all users who logged in.

    It is used on thefollowing 3 situation but not limited:

       School has noserver.

       School has aMac server.

       School has a PCserver, but some AD user groups have to use local TCP/IP printer.

 

Introduction:

In a PC server school, student printing is managed on serverand teachers can put network printer connection easily too. In a none-PC serverschool, school tech may have to set up TCP/IP printer on each PC for teachersand/or students manually for now. Doing this manual setup is a time consumingtask, especially for a number of computers. The purpose of this program is tofill the gap to provide a simple and easy way for school tech to set up printeron PCs.

 

On a PC server, we manage menus$ share and put a printerlist file in "location" folders which is defined in computers'Location field on AD. This program does the similar way and provides moreoptions.

 

Printer Configuration:

Setup a local printer is different from a network printerconnection, it asks for

model, driver, TCP/IP port, and others. So we must defineeach printer configuration first. All printer configuration information is storedin 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 PrinterConfiguration file:

This file is a standard DOS text file. Each line defines oneand 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 printersis 500.

Lines starting with # are comments. Spaces before and behindeach field will be ignored.

 

Specification of eachfield:

Permission: either A or S

1.    A = All users can print

2.    S = Staff only can print

PrinterName:

The printer name shows in thePrinters and Faxes list in XP.

 

IP:

A valid IP address or the Printername which is defined in DNS.

Driver's Inf File:

The UNC name of a printer driver INFfile, it must be in the driver path.

If this field="", thensystem will not install any driver, it assumes

The driver exists in systemprinter cab.

Printer Model:

The printer model driver name.This name is listed on printer driver list.

Locations:

Optional, the printer location inthe printer Property's Location field.

Comment:

Optional, the printer comment inthe printer Property's Comments field.

 

For example:

A, P241LAB1,10.23.66.2,  ./HPUPD/hpcu109c.inf, HPUniversal Printing PCL 6, Computer Lab, For All students and Staff

 

It defines a "P241LAB1" printer, whose IP addressis 10.23.66.2, the printer driver INF file is in a subfolder "HPUPD",of current folder,  file name ishpcu109c.inf, the printer model driver name is "HP Universal Printing PCL6", the location is "Computer Lab", the comment is "For Allstudents and Staff", and all users(staff and students) can print to it.

 

Location List file:

What printers are set up on acomputer is determined by it’s location. A computer’s location can be definedin AD, or in a Location List file. A location List file is a standard DOS textfile 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 # arecomments. Spaces before and behind each field will be ignored.

Location:

            Thelocation name. this name is a location file name.

ComputerName:

            Thecomputer 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 anda default printer.

This file’s format is simple. It lists all the printers thatthis location’s computers can access. The file name is the location name, forexample, location Library has a location printer list file named “Library.txt”.

Each printer occupies one line. The printer name must be sameas the one in Printer Configuration file. The first printer on the list is thedefault printer. Spaces before and behind will be ignored.

There’s a special Location Listfile, Default.txt. All the computerswhich 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.inifile, for example, lab; and make the location name as file name to open thelocation printer list file, lab.txt, and read the printer list, for eachprinter, read printer configuration PrinterConfig.ini,and then set it up.

 

Usage:

    cscriptPrinterSetup.vbs [options….]

 

/c: define school code, this code is used for configurationfiles name only.

/l [0|1|2]: log message level.

    Log Level:

    0: only systeminfo

    1: Error only

    2: Error andwarning messages

    3: All messages

/d: Delete all TCP/IP ports and printers first.

/p: the full path of configuration files. Default=the sameas script’s.

/?: online help.

 

Please put SetACL.exe file with this script.

 

Put all together:

Best practice:

    1. Collect allschool computers name with locations.

    2. Collect allprinters and what locations computer will printer to it.

    3. Define alocation name for each group of computers which have same printers

       to print.

    4. Create printerconfiguration file, named "PrinterConfig.ini",and add printers.

    5. Update computerlocation in AD, or add all computers location to "Locations.ini" file, and remember which method you chose. Fileot AD?

    6. Decide where tosave 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 locationmachine? write down the location.

       Save these files to the destinationfolder.

    7. Test it withdebug log level to 2 or 3. Check the info messages. Go back to make changes ifprogram reports warnings or errors.

    8. Set log levelto 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.inifile:

S, P999CPY1, 10.45.66.9, ./HPUPD/hpcu109c.inf,       HPUniversal Printing PCL 6,      WorkRoomnear 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,       HPUniversal Printing PCL 6,      WorkRoomnear Office, For All Staff only

A, P999LAB1, 10.45.66.5, ./HPUPD/hpcu109c.inf,       HPUniversal Printing PCL 6,      WorkRoomnear 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

 

原创粉丝点击