Running and managing programs


To run programs, open documents and run Windows commands the "Windows Command" step is used.

It is difficult to overestimate the capability of this step, because in addition to other things, it can send documents to print, finish the program, hide and resize windows.

WARNING! If the step is used to run applications or open a page on the Internet, it is desirable to set the "Step timeout" ("Common" panel) for 10 seconds or more for the immediately following step. This will increase the reliability of the task performance, as the time needed to run the program can vary greatly depending on the workload of the computer, the network speed and many other factors, even if the usually automated program starts quickly.

Running the program

Most often the step "Windows Command” is added to the task that runs the automated program. In this case, the program is given a name and, if necessary, the path to the file and start-up parameters.
The name of the program can be entered manually and selected using the file selection dialog or the drop down list that duplicate the “Start” menu items"
Startup options are written on one line and are separated by spaces. If the parameter can contain spaces, it must be specified in double quotes.
Program file name and startup parameters can be substituted by variables or expressions from MouseRobot.
The "Display Mode" field allows you to redefine the mode of the program window after the start-up. By default, the size and mode of the windows are determined by the starting program independently (the "Show window" mode), however, you can run the program minimized, maximized or hidden, if necessary.
The "Default Directory" field allows you to specify in which directory the program will be primarily searched for (if it has no full path specified), as well as the files referred to it as the parameters. Please note, that changing the default directory will affect only the starting program.

The opening of a document or a web page

To open a document or a web page in the program by default, the name of the document and the path in the "Command, object or file" needs to be specified
The operation can be explicitly specified for the file if necessary (e.g. "open", "edit" or "print").
If a document or a web page needs to be open in a specific program (possibly different from the program, assigned in the system by default for the file type), the program name should be specified in the "Command, object or file" field and the file name or the Web address to be specified in the field "Options".

Examples of commands:

Command

Parameters

Action

Description

"D:\1.docx"

-

run

open the document 1.docx in the associated program (in MS Word or other) in the selected display mode

"D:\1.docx"

-

edit

open the document 1.docx in the associated program (in MS Word or other) in the selected display mode

"D:\clear.xtsk"

-

run

run the MouseRobot macro

"D:\clear.xtsk"

-

edit

open MouseRobot macro for editing

www.google.com

-

run

load Google page in your default browser

iexplore

www.google.com

run

load Google page in Internet Explorer

Directing the window of the program

To direct the window that runs the programs, refer to it by specifying the appropriate variable ({LastControl} to control the last found window, {LastProcess} to control the window of recently run programs, etc.) in the field "Command, object, or file", and in the field "Action" select "Show window".
The required mode of the program window: minimized, maximized, to full screen or hidden is given in the field "Display Mode".

Examples of commands:

Command

Action

Display mode

Description

{LastControl}

close

-

close the application  that owns {LastControl}

{LastControl}

kill

-

kill the application that owns {LastControl}

{LastControl}

show

show

hide

show minimized

show maximized

show normal

show the window that owns {LastControl} in the chosen display mode

{LastProcess}

close

-

close the application {LastProcess}

{LastProcess}

kill

-

kill the application {LastProcess}

{LastProcess}

show

show

hide

show minimized

show maximized

show normal

shows the main window of application {LastProcess} in the selected display mode

Sending a document to print

To send a document to print, one should specify the path and the name of the document in the field "Command, object or file" and choose the action "Print". Note that this method will work only, if this type of document is associated with the command of print. The document will be displayed with the print settings by default.

WARNING! To check whether the document is associated with the print command, you can open the context menu of the document in Windows Explorer. If the print command is assigned, then the menu will display "Print."

Examples of commands:

Command

Action

Description

"D:\1.docx"

print

open the document 1.docx in the associated program (in MS Word or other), call the print command, close the program

Command Execution

The Microsoft Windows software has a large number of commands and utilities able to solve almost any problem on the system control, files, settings, etc. Some of them are separate programs (e.g.: ping, telnet, ftp, rundll), while others are the built-in commands and are not stored physically on the disk (for example: copy, del, move, mkdir).
To run the Windows commands, you need to specify its name in the "Command, object, or file" field and fill in the settings according to the command syntax. It is also recommended to enable the flag "Wait for termination" because otherwise the task will continue until the completion of the command, which can lead to unpredictable consequences. In addition, the code with the command execution result can only be obtained with the active flag "Wait for termination".

Examples of commands:

Command

Parameters

Description

copy

"c:\folder1\doc1.txt" "c:\folder2"

copy doc1.txt from c:\folder1 to c:\folder2

rundll32

shell32 SHExitWindowsEx 2

restart a computer

ftp

-s:ftpcommands.txt ftp.microsoft.com

connect to ftp.microsoft.com and run commands from file ftpcommands.txt.
For example, load the file "file.txt":
get file.txt c:\temp\file.txt

ping

google.com

check connection between  network nodes - if there is connection between current computer and google.com, then {LastProcessExitCode} = 0

WARNING! By default, when executing the command, MouseRobot checks only the success of its running, but not the result of performance. Compare the value of the variable {LastProcessExitCode}, set after the command execution, with zero, to verify the success of execution. By the value of the same variable, you can determine the type of error, which occurred at the command execution. Decoding the error codes is specific for each command, and can be found in Windows documentation.

Forcible Termination of Program

To finish the program being executed, it necessary to refer to it using the variables {LastProcess} or {LastControl}, and choose the "Kill" function. In this case, the program will be forcibly terminated and any unsaved data will be lost. Therefore, it is desirable to use the forced termination of the program only in exceptional cases: when the program is "frozen", or there is no other possibility to interrupt the prolonged operation it is executing.