Starting Applications and Opening Documents



START-APP: <command until the end of line>

Starts an application and proceeds to the next line of current task without waiting for the application to be closed.

Arguments of word START-APP: may include path to the desired program or document, name of the executable file and all required command line parameters. If the argument contains a name of a document rather than that of an executable file, nnCron will open this document in a program which is the registered program for files of this type.

Examples:

#( test_start_app
\ starting Internet Explorer on every week day at 10:00 A.M.
Time: 0 10 * * 1-5 *
Action:
START-APP: C:\Program Files\Internet Explorer\iexplore.exe
\ after Internet Explorer has been started, nnCron proceeds to 
\execute the remainder of the task
)#
#( test_start_app1 \ starting backup copying on Mondays and Thursdays at 2:30 A.M. Time: 30 2 * * 1,4 * Action: START-APP: nnbackup.exe sync -i d:\fido -o g:\backup\fido -s -v -e -da )#

There also exists a postfix version of this word:

S" app_name" START-APP

Attention, please: you cannot use the postfix word START-APP in console. To start an application from console use the word StartApp ( si a u -- ?):

0 S" app_name" StartApp DROP

See also "Options for Running Applications and Opening Documents", PROC-WAIT-IDLE.


START-APPW: <command to the end of line>

This word works similarly to START-APP:, but after starting an application it awaits for its completion, i.e. the next line in the task will be executed only after the application has been stopped.

Example:

#( test_start_appw
\ starting Internet Explorer on every week day at 10:00 A.M.
Time: 0 10 * * 1-5 *
Action:
START-APPW: C:\Program Files\Internet Explorer\iexplore.exe
\ the remainder of task will not be executed
\ until Internet Explorer window is closed by the user
)#

Word START-APPW: permits to access the errorlevel code returned by the program which it started. The errorlevel number is stored in variable ExitCodeProc.

Example:

\ display a message if  errorlevel number  is not equal to zero 
START-APPW: xxx.exe
ExitCodeProc 0 <> IF MSG: "Error %ExitCodeProc%!" THEN

Besides the standard set of options running applications, you can use option WaitFor: <ms or hh:mm> before START-APPW:; this option will terminate the application if it has not completed its work during specified period of time.

There also exists a postfix version of this word:

S" app_name" START-APPW

Attention, please: you cannot use the postfix word START-APPW in console. To start an application from console use the word StartAppWait ( si a u -- ?):

0 S" app_name" StartAppWait DROP

See also "Options for Running Applications and Opening Documents".


QSTART-APP: <command to the end of line>

This word works similarly to START-APP:, but before starting an application, it will display a dialog box asking: "Would you like to run application?". The application will be started only if the user selects Yes.

Example:

#( test_start_app
\ every week day at 5:30 P.M., asking user's permission  
\ to start Internet Explorer
Time: 30 17 * * 1-5 *
Action:
    QSTART-APP: C:\Program Files\Internet Explorer\iexplore.exe
)#

See also "Options for Running Applications and Opening Documents", PROC-WAIT-IDLE, QueryStartTimeout:, QueryStartAnswer:.


Options for Running Applications and Opening Documents

There are certain options for running applications and opening documents which can be used with words START-APP:, START-APPW: è QSTART-APP:; these options determine how applications will be started and how documents will be opened. Options should be separated by a blank space, a tabulation symbol or a newline symbol. They are placed before words which they modify.

StartIn: "dir_path" Sets the directory in which the application will be started.
ShowNormal
SWHide
ShowMaximized
ShowMinimized
ShowNoActivate

Options for displaying application window:

  • Start in normal mode
  • Hide program window
  • Maximize
  • Minimize
  • Do not make the window active when starting application
StartPos: <x> <y> Specifies the absolute position of a window (in pixels)
StartSize: <xsize> <ysize> Specifies window size (in pixels)
HighPriority
IdlePriority
NormalPriority
RealtimePriority
AboveNormalPriority
BelowNormalPriority

Sets a process's priority.

Works only in WinNT/2000/XP, and words AboveNormalPriority and BelowNormalPriority - only in Win2000/XP.

AsService

Starts an application as a service. This means that the program started in this way will not be terminated on user log-off. Option AsService permits nnCron to perform functions of utility SRVANY.EXE fromWinNT Res. Kit.

Works only in WinNT/2000/XP.

Title: "console_title" Sets a console window's title immediately on the application's startup. Works only with console windows..

WaitFor: <ms>
WaitFor: <hh:mm>

Terminates an application if it has not completed its work or been closed by a user during a specified period of time.

Works only with word START-APPW:.

Example:

#( backup_fido_and_tools
\ NoActive
Time: 30 2 * * 1,4 *
Action:
    StartIn: "\tools\nnbackup"
    ShowMinimized NormalPriority
    START-APPW: nnbackup.exe sync -i d:\fido -o g:\backup\fido -s -v -e DA
    LOG: "log\nncron.log" " > Exit Code: %ExitCodeProc% > FIDO backup"
   
    StartIn: "\tools\nnbackup"
    ShowMinimized NormalPriority
    START-APPW: nnbackup.exe sync -i d:\tools -o g:\backup\tools -s -v -e DA -x *.lck
    LOG: "log\nncron.log" " > Exit Code: %ExitCodeProc% > Tools backup"
)#