Free 14-Day Evaluations    
Product Downloads    

Sign in     


DESKTOP MOBILE DOWNLOAD PURCHASE SUPPORT INFO COMPANY
 Home  >>  Support  >>  Knowledge Base

Launch Windows-Based Application from TinyTERM

There is a command in the CScript language that will launch a Windows-based application: spawn(). Here is the function definition from the TinyTERM Programmers Reference Manual:

Void Spawn(iWait, sCmdString, sArguments )
Passes sCmdString to the operating system to be run with the arguments sArguments. Note that the command name, without an extension, must always be the first argument in sArguments. Note that you cannot use quotes as part of sCmdString or sArguments, so if you must launch an application with a space in its Windows filename, you must use DOS 8.3 filenames to refer to that application with the spawn command.

iWait
0 Wait until spawned process ends before running next command
1 No wait
2 Detach spawned process from the console
3 Wait for spawned process to complete its startup procedures before continuing with the next command

For example, the following script command will launch the Notepad application and open the file untitled.txt:

spawn( 0, “notepad.exe”, “notepad untitled.txt”);

A similar command would look like this for Acrobat Reader 5.0:

spawn(1,”C:\Progra~1\\Adobe\\Acroba~1\\Reader\\AcroRd32.exe”,”AcroRd32 D:\path\document.pdf”);

Note the use of \\ as a directory separator. You can also use / if you prefer.

This doesn’t work with some command-line programs, like the ECHO command and batch files. Batch files and a number of Windows internal commands run through the COMMAND.COM or CMD.EXE program. You have to make that program part of the spawn() string, using the /C option. Whether you use COMMAND.COM or CMD.EXE depends on your version of Windows.

For example, suppose you need to copy a text file to the printer port. COPY is part of COMMAND.COM, so the equivalent spawn() item would be:

spawn(1,”command.com”,”command /c copy file.txt > lpt1:”);

The same syntax will work for a Windows batch file:

spawn(1,”command.com”,”command /c execute.bat”);

You can also use this to launch any document with the Windows START command. Again turning to Adobe as an example, the following command will run any version of Acrobat Reader that’s installed, loading the file document.pdf:

spawn(1,”cmd.exe”,”cmd /c start D:\\path\\document.pdf”);

Century Software, Inc., has had a request to bypass the need for START. When a file name is passed, it would use the existing Windows file associations to determine the correct application.

CR 687

Comments are closed.

  Copyright © 2024 Century Software, Inc. All Rights Reserved999 TERMS OF USE PRIVACY POLICY EULA