Printer - Get printer(s)

Declaration

<AMPRINTER RESULTVARIABLE="text" RESULTDATASET="text" REMOTEMACHINE="text" REMOTEDOMAIN="text" REMOTEUSERNAME="text" REMOTEPASSWORD="text (encrypted)" />

Related Topics   

Description

Retrieves a list of printers installed locally or on a remote computer and populates an existing variable with the printer currently set as default. This activity can also create and populate a dataset with information about each printer, such as name, status, device ID, etc.

Practical Usage

Ideal for retrieving status and other printer related information as a way to manage which printers and at what time print jobs should take place.

Parameters

General

Property Type Required Default Markup Description
Populate variable with default printer name Text Yes (Empty) RESULTVARIABLE="printerName" The name of an existing variable to be populated with the name of the printer currently set as default.  
Create and populate dataset (optional) Text No (Empty) RESULTDATASET="printerInfo" The name of the dataset to create and populate with information about each printer found. For more information regarding this dataset, see Datasets below.   

Computer

Property Type Required Default Markup Description
Local computer --- --- --- --- If selected, retrieves a list of all printers connected to the local computer (enabled by default). Selecting this parameter disables the Remote computer parameter.
NOTE: This parameter does not contain markup and is only displayed in visual mode for task construction and configuration purposes.
Remote computer --- --- --- --- If selected, retrieves a list of all printers connected to a remote computer (disabled by default). If this parameter is selected, the Local computer parameter becomes disabled.
NOTE: This parameter does not contain markup and is only displayed in visual mode for task construction and configuration purposes.
Computer Text Yes, if Remote computer is selected (Empty) REMOTEMACHINE="compName" Specifies the name of the remote computer. This parameter becomes active and is required if the Remote computer parameter is selected.
Domain Text Yes, if Remote computer is selected (Empty) REMOTEDOMAIN="DomainName"

Specifies the domain used by the remote computer. This parameter becomes active and is required if the Remote computer parameter is selected.

Username Text Yes, if Remote computer is selected  (Empty) REMOTEUSERNAME="Username" A valid username to use to log onto the remote computer. This parameter becomes active and is required if the Remote computer parameter is selected.
NOTE: This user must have proper permissions to modify printers on the remote machine.
Password Text Yes, if Remote computer is selected (Empty) REMOTEPASSWORD="encrypted" The corresponding password to use with the selected username. This parameter becomes active and is required if the Remote computer parameter is selected.

Description

Error Causes

On Error

Additional Notes

Datasets

A dataset is a multiple column, multiple row container object. This activity creates and populates a dataset with the following fields (rows):

Name Type Return Value
theDataset.DeviceID Number The printer's device ID
theDataset.DriverName Text The printer's driver name.
theDataset.IsDefault True/False Returns TRUE if the printer is currently set as default. Otherwise, returns FALSE.
theDataset.IsQueued True/False Returns TRUE if the printer is currently queued. Otherwise, returns FALSE.
theDataset.IsShared True/False Returns TRUE if the printer is shared. Otherwise, returns FALSE.
theDataset.PortName Text The printer's port name.
theDataset.PrinterName Text The printer's name.
theDataset.Status Options The status of the printer (i.e. Online).

Example

NOTE:
  • The sample AML code below can be copied and pasted directly into the Steps Panel of the Task Builder.
  • Parameters containing user credentials, files, file paths, and/or other information specific to the task must be customized before the sample code can run successfully.

Description

This sample task retrieves printers connected to the local computer, displays the default printer's name in a dialog box, and then loops through each connected printer and display information about the current in a separate dialog box.

Copy
<AMVARIABLE NAME="DefaultPrinter" VALUE="" />
<AMPRINTER RESULTVARIABLE="DefaultPrinter" RESULTDATASET="PrinterInfo" LOCAL="yes" />
<AMSHOWDIALOG WINDOWTITLE="Default Printer Name" BUTTONS="ok_cancel" ONSECONDBUTTONCLICK="stop">The name of the default printer is:%DefaultPrinter%</AMSHOWDIALOG>
<AMLOOP ACTIVITY="dataset" DATASET="PrinterInfo" />
<AMSHOWDIALOG WINDOWTITLE="Current Printer Information" BUTTONS="ok_cancel" ONSECONDBUTTONCLICK="stop">Information about the current printer:Printer Name: %PrinterInfo.PrinterName%Printer Status: %PrinterInfo.Status%Printer Device ID: %PrinterInfo.DeviceID%Is printer shared? %PrinterInfo.IsShared%Is printer currently queued? %PrinterInfo.IsQueued%</AMSHOWDIALOG>
<AMLOOP ACTIVITY="end" />
Copy
<AMVARIABLE NAME="DefaultPrinter" VALUE="" />
<AMPRINTER RESULTVARIABLE="DefaultPrinter" RESULTDATASET="PrinterInfo" LOCAL="yes" />
<AMSHOWDIALOG WINDOWTITLE="Default Printer Name" BUTTONS="ok_cancel" ONSECONDBUTTONCLICK="stop">The name of the default printer is:%DefaultPrinter%</AMSHOWDIALOG>
<AMLOOP ACTIVITY="dataset" DATASET="PrinterInfo" /><AMSHOWDIALOG WINDOWTITLE="Current Printer Information" BUTTONS="ok_cancel" ONSECONDBUTTONCLICK="stop">Information about the current printer:Printer Name: %PrinterInfo.PrinterName%Printer Status: %PrinterInfo.Status%Printer Device ID: %PrinterInfo.DeviceID%Is printer shared? %PrinterInfo.IsShared%Is printer currently queued? %PrinterInfo.IsQueued%</AMSHOWDIALOG><AMLOOP ACTIVITY="end" />