In order to invoke a Windows shell function (such as a batch file or executable) from APPX for Windows, you can use a syntax similar to the following. (You'll have to break the SET statement apart into multiple APPENDs, but it is presented here as single strings, for clarity.)
SET --- TEMP 2K = /w cmd.exe /c " APPEND --- TEMP 2K 0 --- TEMP 512 APPEND --- TEMP 2K 0 " RUN --- TEMP 2K END? N FAIL 0This assumes the command we want to run is already formatted in --- TEMP 512. We enclose the entire command in quotes in case of embedded spaces. The '/w' switch tells APPX to wait for the command to complete before continuing. If you don't need to wait, you can leave that switch out. You can also use the full path & file name of a file directly in the RUN command, ie, RUN C:\WINDOWS\SYSTEM32\NOTEPAD.EXE, however note that APPX will not wait for the command to complete. If you need to wait for the command to complete, use the '/w cmd.exe /c' syntax. Remember that when you use the RUN command, it will be executed on the server, not the client. If you need to run the command on the client PC, see .CLIENT LOAD URL. To pass parameters to the command, simply execute PASS <field name> or PASS <Filename>, then append a $* to your command. For example:
SET --- TEMP 80 = APARAMETER PASS --- TEMP 80 FIELD SHARE? N PASS CAR CUSTOMER FILE SHARE? N SET --- TEMP 79 = D:\TEST.BAT $* RUN --- TEMP 79 END? N FAIL 0Executing a PASS with the File parameter will pass the complete path of that file to the command (without the .dat extension). You can also control the order the parameters are PASSed. The '$*' syntax will PASS the parameters in the order of the PASS statements, but you can also refer to '$1', '$2', etc. In the example above, if we executed 'D:\TEST.BAT $2 $1', the batch file would receive the path to CAR CUSTOMER first, followed by the contents of --- TEMP 80. See Passing Fields or File Names for more information passing values to external commands.
SET --- TEMP 132 = cmd.exe /c C:\APPX\scripts\test.bat RUN --- TEMP 132Windows 9x, APPX 4.0.2 and after:
SET --- TEMP 132 = C:\command.com /c C:\APPX\scripts\test.bat RUN --- TEMP 132Windows NT, prior to APPX 4.0.2:
SET --- TEMP 132 = cmd.exe /c C:\\APPX\\scripts\\test.bat RUN --- TEMP 132Windows 9x, prior to APPX 4.0.2:
SET --- TEMP 132 = C:\\command.com /c C:\\APPX\\scripts\\test.bat RUN --- TEMP 132In the above example, "test.bat" contains some DOS copy commands. DOS commands (such as 'copy') don't work directly from APPX, because we are using a Windows "exec" function, which only knows how to start Windows programs. But running command.com from Windows, with the "/c" switch, creates a temporary DOS shell, which can then execute a DOS batch file. The "/c" after cmd.exe and command.com specifies that the command interpreter is to perform the command specified by the string following it, in this case a batch file, and then stop. Note that you can use option 6)Upper/Lower in the ILF editor to get lower case characters, such as 'cmd.exe'. In releases 4.0.1 and prior, the double backslashes ("\\") are necessary to pass a single backslash ("\") thru to the windows shell, since backslash is used in DOS to denote special treatment of the following character. In release 4.0.2 and after, the double backslash is no longer required. Running command.com /c or cmd.exe /c is only necessary when invoking non-Windows native applications. This includes commands one would normally execute from the DOS popup box. If you want to run a Windows-native application (such as notepad, or MS Access), you can invoke this directly without the command.com or cmd.exe /c prefix. Without a preceding backslash, a "$" is an indicator of a substitution in the RUN command string based on a PASS statement. A backslash preceding a "$" tells APPX not to do a substitution but to allow the "$" to remain in the RUN command string. (And the '%' symbol?)
echo - display statement in the DOS box. copy - execute statement and display in DOS box. pause - display "Press any key to continue" and wait for user to press enter before proceeding. choice - display the message, waited for user to make a valid selectionTo accomplish this, make a copy of COMMAND.COM and put it into a test directory. In the PROGRAM tab of PROPERTIES for this new file, deselect the "Close on Exit" check box. Then modify the APPX subroutine to invoke this test copy of COMMAND.COM. Now everything should continue to work fine and the box remain on screen. The title bar should at the end say: "Finished - " when complete.
=
=================================== 013 REMOVE DIRECTO+------------------------------------------------+ 014 SUBMIT JOB & Command String & 015 GET SESSION PI& & 016 KILL TASK &cat6 & 017 VIEW FILE &{PRINTQ.HEX OPTIONS}6 & XX8 SUBMIT PRINT J&{BANNER FILE}6 & &{PRINTQ.PATH FILE}6 & &|lp -oraw6 & &{PRINTQ.SUBMIT DETAIL}6 & &2>&1 |awk '/^request id is/{print "0" \$4}6 & &/^\\/usr\\/bin\\/lp/{print "1" \$0}' & & & & & +------------------------------------------------+
After:
000 GET HOST NAME +------------------------------------------------+ 001 CANCEL PRINT J& Command String & 002 GET PROCESS ID& & 003 COPY A FILE &cat6 & 004 REMOVE FILE &{PRINTQ.HEX OPTIONS}6 & 005 GET GROUP LIST&{BANNER FILE}6 & 005 START BACKGROU&{PRINTQ.PATH FILE}6 & 006 LOOK FOR PRINT&|lp -oraw6 & 007 GET SYSTEM PRI&{PRINTQ.SUBMIT DETAIL}6 & 008 SUBMIT PRINT J&2>&1 |awk '/^request id is/{print "0" \$4}6 & 009 GET DIRECTORY &/^\/usr\/bin\/lp/{print "1" \$0}' & 010 GET NAME FROM & & 011 GET SYSTEM JOB& & 012 RENAME A FILE +------------------------------------------------+