Printer - Get Printers
Declaration
<AMPRINTER RESULTVARIABLE="text" RESULTDATASET="text" REMOTE="yes/no" REMOTEMACHINE="text" REMOTEDOMAIN="text" REMOTEUSERNAME="text" REMOTEPASSWORD="text (encrypted)" />
Description: Retrieves a list of printers connected locally or on a remote computer and populates an existing variable with the printer currently set as default. In addition, it can also create and populate a dataset with information about each printer, such as printer 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.
General Parameters
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 |
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 Parameters
Property |
Type |
Required |
Default |
Markup |
Description |
---|---|---|---|---|---|
Local computer |
|
|
|
|
If enabled, indicates that printers connected locally will be searched (enabled by default). If this parameter is selected, the Another computer parameter becomes inactive. This is a visual mode parameter used during design time only, therefore, it contains no markups. |
Another computer |
|
|
|
|
If enabled, indicates that printers connected to a remote computer will be searched (disabled by default). If this parameter is selected, the Local computer parameter becomes inactive. This is a visual mode parameter used during design time only, therefore, it contains no markups. |
Computer |
Text |
Yes if set to Another computer |
(Empty) |
REMOTEMACHINE="MachineName" |
The name of the remote computer to retrieve printer data from. This parameter is active only if the Another computer parameter is enabled. |
Domain |
Text |
Yes if set to Another computer |
(Empty) |
REMOTEDOMAIN="DomainName" |
The domain that the remote computer belongs to. This parameter is active only if the Another computer parameter is enabled. |
Username |
Text |
Yes if set to Another computer |
(Empty) |
REMOTEUSERNAME="Username" |
A valid username used to log onto the remote computer. This user must have proper permissions to modify printers on the remote machine. This parameter is active only if the Another computer parameter is enabled. |
Password |
Text |
Yes if set to Another computer |
(Empty) |
REMOTEPASSWORD="encrypted" |
The password associated with the username entered above. This parameter is active only if the Another computer parameter is enabled. |
Description tab - A custom description can be provided on the Description tab to convey additional information or share special notes about a task step.
Error Causes tab - Specify how this step should behave upon the occurrence of an error. (Refer to Task Builder > Error Causes Tab for details.)
On Error tab - Specify what AWE should do if this step encounters an error as defined on the Error Causes tab. (Refer to Task Builder > On Error Tab for details.)
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 (e.g., Online). |
Example
The sample AML code below can be copied and pasted directly into the Steps panel of the Task Builder.
Description: Retrieve printers connected to the local computer and display the default printer's name in a message. Then, loop through each connected printer and display information about the current in a separate message box.
<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>