Introduction
AnzioWin includes a feature that accepts commands through host scripting, including the ability for a host script or host application to start a Windows application. This document describes how this works.
Running a Windows application from the host
One of the big benefits of AnzioWin over other terminal emulation and telnet products is its ability to respond to host commands issued from a server-side application or script.
Commands are sent through the AnzioWin session by bracketing the commands in a hex-1C (octal 34) and hex-1D (octal 35). Optionally, you can utilize other escape sequences if necessary.
Your host program or shell script simply needs to be able to display the string to the screen. AnzioWin will intercept the information and interpret it, passing it on to Windows.
Starting a Windows application can be initiated at the host or server side with something as simple as a one line script:
printf "\034winstart notepad\035 "
Note: In the case of "notepad", Windows default path already explicitly list "C:\WINDOWS\SYSTEM32\" and hence a path is not required. However for other application, a path and file extension may be necessary. If the path contains spaces, optional quotes should be added around the executable name. Depending on the shell you are working under, you may need to escape any back-slashes for directory names and any quotes.
Starting a Windows "File Association"
As with running a program, this approach can be used to open any file on the PC through a file association. This would be similar to double clicking on a file through Windows Explorer shell - if a file association is registered with Windows, the file should open in the appropriate application.
As above, this can be initiated with something as simple as a one line script:
printf "\034winstart \"c:\\\\my documents\\\\mydocument.pdf\" \035 "
Note: If there are embedded spaces in the file path or file name, be sure to enclose the whole file name in quotes. Also, back-slashes and quotes need to be "escaped", (as an example four back-slashes are needed for a single back-slash and a single back-slash before a quote for quotes to work in my bash shell setup). This may vary depending on the shell. A little experimentation may be necessary.
Additional documentation on sending AnzioWin commands can be found in several other knowledgebase articles as well as examples in the AnzioWin manual:
The Commands
WINSTART filename [params]
This function will ask Windows to open the filename or run the executable, passing any given parameters as command line switches. This command also supports AnzioWin environment variables (see below). Control is immediately returned to AnzioWin.
LAUNCH [options] program [parameters]
Launch will start a Windows program similar to RUN below. However, LAUNCH will not wait for the application to end before returning control, allowing the programs to run side by side. Possible options are
/MIN Minimize the program's window
/MAX Maximize the program's window
/HIDE Hide the program's window
/nnn The numeric value nnn is equivalent to that used by VBScript, etc.
LAUNCH/S [options] program [parameters]
Identical to LAUNCH above except a status code is sent back to the host on whether the application started successfully.
RUN [options [program [parameters]]
This function will run a Windows application. AnzioWin control is returned when the application ends and the user acknowledges return to AnzioWin. Possible options are
/MIN Minimize the program's window
/MAX Maximize the program's window
/HIDE Hide the program's window
/nnn The numeric value nnn is equivalent to that used by VBScript, etc.
RUN/N [options] [program [parameters]]
Similar to RUN, a Windows program is called and return to AnzioWin happens when the program ends. However, acknowledgement by the user is not required. Possible options are
/MIN Minimize the program's window
/MAX Maximize the program's window
/HIDE Hide the program's window
/nnn The numeric value nnn is equivalent to that used by VBScript, etc.
RUN/S [options] [program [parameters]]
Similar to RUN, the /S will cause the programs exit code to be returned through to the host application. Possible options are
/MIN Minimize the program's window
/MAX Maximize the program's window
/HIDE Hide the program's window
/nnn The numeric value nnn is equivalent to that used by VBScript, etc.
Environment variables
AnzioWin includes a set of common environment variables that can also be included in the filename or the executable name when launching or running an application from the host through AnzioWin. These are documented in the AnzioWin manual and are too numerous to explain here.
However, it is worth noting how to use them with some examples:
winstart ${anz_last_recd}
(this command would open the last file received through a file transfer with a file association)winstart ${ANZ_MY_DOCS}\\\\MYDOCUMENT.DOC
(start a document)
Security concerns
With this functionality comes some security concerns. Within AnzioWin you can enable or disable these types of commands from taking place. You can also select alternate escape sequences to be watched other than hex 1C and hex 1D.
To control these functions, go to Advanced Options under the Edit menu and the Security tab. From here you can either enable or disable AnzioWin watching for the hex 1C sequence.
Note: If you are running in "kiosk mode", you can also allow or prevent these sequences from working with the "Allow functions in kiosk mode" check box.
Some examples
PERL Example
#!/usr/bin/perl
#
# This is a sample perl script starts a Windows application - NOTEPAD
#$begCMD = "\034"; # Start a command for Anzio
$endCMD = "\035"; # End a command for Anzioprint "$begCMD env/s ANZ_PROGRAM$endCMD"; # Get the Anzio program name
$anzioprogram = <STDIN>;
chop $anzioprogram;if ($anzioprogram ne "ANZIOLITE")
{
print "$begCMD winstart notepad$endCMD";
}
Script Example
#!/bin/sh
#
read -p '\\034env/s ANZ_PROGRAM\\035' prog
if [ $prog = 'ANZIOWIN' ]; then
printf "\034run/n ftp.exe \035"
fi
- Anzio
- Using Anzio's features
Related Topics
- Scripting AnzioWin from Perl
- Scripting with Microsoft Script Control in AnzioWin
- Scripting AnzioWin from the Host