NetPrinters
Copyright © 2008 Daniel Collins
Website:
http://www.solemnwarning.net/netprinters/
NetPrinters is a utility for managing networked printer connections on Windows
workstations running Windows 2000 or newer. It can be passed printers via the
command line, or in a NetPrinters script which allows setting up printers based
on filters such as username and hostname.
Command line options
- -a
Print "about" message.
- -e
Print environment information (username, hostname, etc)
- -c \\SERVER\PrinterName
Add printer connection to specified SMB printer.
- -d \\SERVER\PrinterName
Set default printer to specified SMB printer.
- -r Expression
Remove all printer connections matching the supplied expression.
- -l
List connected printers.
- -s Filename
Execute a NetPrinters script.
Script format
NetPrinters scripts are made from "blocks" of code, blocks of code contain
control and filter directives, the control directives of a block are executed
in order until a filter statement that evaluates false is encountered, then the
rest of the block is skipped.
Blocks of code are seperated by one or more blank lines, lines beginning with a
hash (#) symbol are ignored as comments, but they will not act as block
seperators.
Control directives
- AddPrinter \\SERVER\PrinterName
Add printer connection to an SMB printer.
- DefaultPrinter \\SERVER\PrinterName
Set default printer to specified SMB printer.
- DeletePrinter \\SERVER\PrinterName
Delete any printer connections matching the supplied expression, the printer
expression may make use of the * and ? wildcards to represent zero or more of
any character, or any one character respectively.
Filter directives
- NetBIOS NetBIOS name
Evaluates true if the system NetBIOS name matches the supplied NetBIOS name,
the supplied name may use the * and ? wildcards, which have the same effect as
documented in DeletePrinter.
- !NetBIOS NetBIOS name
Evaluates true is the system NetBIOS name does NOT match the supplied NetBIOS
name, basically the opposite of the NetBIOS directive. May also use the * and ?
wildcards like NetBIOS can.
- Username Username expression
Evaluates true if the current username matches the supplied username expression,
the supplied username expression may use the * and ? wildcards.
- !Username Username expression
Evaluates true if the current username does NOT match the supplied username
expression, the supplied username expression may use the * and ? wildcards.