Actions

Actions is a feature that allows you to perform operations on network nodes directly from the Network tree.

Actions can be accessed via the network node and group context menus:

If an action is unavailable, it means that the node does not meet one of the Conditions or the Condition cannot be applied to this Network tree node.

See Conditions.

By default, only the actions that are applicable to the selected nodes are visible in the menu. This can be changed from the Options.

Actions can also be executed from the context menus of network map nodes.

Standard actions

TNI comes with three standard actions:

  • Reboot;
  • Power off;
  • Wake-on-LAN.

These actions don’t need to be configured. To execute one of them, simply select it from the action list of the desired node or group of nodes.

If any of these actions are grayed out, the selected devices are most likely located on a different network. In the case of the Wake-on-LAN action, the target device must also be powered off for the option to become available.

Custom actions

Custom actions allow you to use system routines or third-party utilities to perform tasks on remote network devices.

Custom actions are defined in the actions configuration file using a simple syntax. To access the file, right-click any asset, choose Edit actions from the Actions sub-menu, and when the Options window opens, click the Edit commands in Notepad button in Options Actions

A convenient, brief summary of the action definition syntax, with examples and a complete list of keywords and templates, can be found in the Actions section of the Options window, which supports one-click copying. The list is also available on this documentation page.

An example of custom actions for the UltraVNC program:

{$IF WIN,ONLINE}UltraVNC connection=”C:\Program Files\UltraVNC\UltraVNC.exe” -c: -h: -x -a:1 -m:

{$IF ONLINE} Remote VNC=vncviewer.exe -connect host %HOST%

Creating a new action

To add a new action, add a line to the action text file:

Action name=command

Action name is the name that will appear in the Actions menu.

Command is the operating system command to execute.

Templates

Within the command definition, certain string templates are used to pass information about the target network node to the command. These are the supported templates:

An example of using a template in a command

Ping asset=ping.exe %HOST%

Conditions

Conditional directives may be added to the action’s definition, thus rendering the action inapplicable to certain assets. This is useful in a variety of situations; for example, it can prevent attempts to execute commands that are certain to fail.

A condition is specified by adding {$IF condition} before the action definition:

{$IF condition}Action name=command

These are the supported conditions:

Command Description

OPEN00

The specified port is open

OPENSSHPORT

The SSH port specified in the scanner settings is open

ONLINE

The device is online

WIN

The device runs Windows

LIN

The device runs Linux

MAC

The device runs macOS

SSH

The device was scanned via SSH (Linux, macOS, FreeBSD, or ESX/ESXi)

SNMP

The device was scanned via SNMP

LAN

The device and the PC running TNI share the same subnet

EXISTS(filename.exe)

The specified executable exists in one of the directories listed in the PATH environment variable

Command Description
%HOST%

FQDN, hostname or IP, depending on the Static IP address setting of the asset

%HOSTNAME%

Hostname of the asset

%ALIAS%

Alias of the asset

%IP%

IP address of the asset

%MAC-%

Hyphen-separated MAC-address

%MAC:%

Colon-separated MAC-address

%MAC%

MAC-address without delimiters

%SSHPORT%

Custom SSH port as specified in the scanner options

%USERNAME%

Username from the login record used for asset scanning

%PASSWORD%

Password from the login record used for asset scanning

%DATE%

Current date (YYYYMMDD)

%TIME%

Current time (HHMM)

%TIMES%

Current time (HHMMSS)

Multiple conditions separated by commas are evaluated using a logical AND.

Adding an “!” before a condition negates it (logical NOT).

An example of using a template in a command

{$IF LAN,!ONLINE}Wake-on-LAN=wol.exe %MAC:%

Actions for multiple nodes

By default, actions cannot be executed on multiple devices simultaneously. Thus, it won’t appear in the action list when you select several devices or a group. To make it available in these cases, support for multiple targets must be explicitly enabled by adding the {$MULTI} directive in before the definition.

Example

{$MULTI}{$IF LAN,!ONLINE}Wake-on-LAN=wol.exe %MAC:%

When an action targets multiple devices, a condition is considered satisfied if any of the target nodes satisfies it. To make a condition mandatory for all targets, an “!” should be added after it.

Examples:

Command Description

{$IF LAN}

If any of the target nodes share the local subnet

{$IF LAN!}

If all of the target nodes share the local subnet

Negation and the “mandatory for all” modifier can be combined:

{$IF !ONLINE!}If all of the targeted nodes are offline

Grouping actions

The commands {$GROUP} and {$END GROUP} allow you to organize the action list into groups.

Example of usage

{$GROUP}Group name

{$F OPEN80}Browse web=http://%HOST%/

{$END GROUP}

Accidental run protection

If an action is “unsafe”, adding an {$?} directive to the definition will display a confirmation dialog before every execution.

{$?}Shutdown="C:\PSTools\psshutdown.exe" -k \\%HOST%

Sending keystrokes

Sometimes executing a command launches a user interface that requires further user input. In order to automate this task, TNI can send predefined keystrokes to the launched application.

To send keystrokes, append /sendkeys: to the action’s definition, followed by a string of keys to send. After the /sendkeys: command you may use:

Arbitrary textsent as is
Templatesresolved to text and sent
{$WAIT X}pauses the execution for X milliseconds (if this directive is omitted, the default pause before sending any keys is one second)
{key name}simulates pressing a special key (the following keyboard keys can be used: F1..F10, LEFT, RIGHT, UP, DOWN, ENTER, BACKSPACE, PGUP, PGDN, HOME, END, TAB)
Example of usage

Remote Desktop with login=mstsc.exe /v:%IP% /sendkeys:%PASSWORD%{ENTER}

When the action is executed, an authentication window will open. TNI then sends the password to the input box and presses Enter to log in automatically.

Contents