/
system
system
Description
The system command allows you to start processes/applications, or allows you to execute DOS commands when using the -dos
flag.
One way to think of the distinction is to consider the difference between entering values in the Run dialog box, compared with a DOS command prompt.
Functional area
System
Command syntax
Syntax
system "argList" ["startDir"] [-async] [-hide] [-captureOutput] [-dos] [-noFeedback] [-title string]
|
Arguments
Name | Type | Required | Comments |
---|---|---|---|
argList
|
string | yes | When using the -dos flag, this argument is the DOS command you wish to execute. Otherwise this is a string composed of the name of the application you wish you launch (using a full path if the application does not exist in one of the folders in your PATH environment variable) as well as any values you wish to pass to the application as startup/command line parameters. See Examples section below. |
startDir
|
string | no | Allows you to specify the starting "working" directory for the process. By default, the starting directory is the directory which the process is located in. This argument isn't used when you use the -dos flag. |
Flags
Name | Flag arguments | Argument type | Excl. to | Comments |
---|---|---|---|---|
async
|
0 | — | captureOutput | Set this flag to launch the process in a separate thread so that Shogun Post does not lock up while the program is running. By default, Shogun Post waits for the process (or DOS command) to finish. |
hide
|
0 | — | dos | Set this flag to launch the process with the process` window hidden. |
captureOutput
|
0 | — | async, dos | For processes that are console applications, this flag redirects the output normally sent to the console window to Shogun Post's command log. This output is also used as the return value. |
dos
|
0 | — | hide, captureOutput | This flag causes the system command to invoke the DOS command interpreter through the C Runtime system() command. Use this flag if you want to execute one of the available commands of the DOS command interpreter (e.g. the dir del commands). By default, the system command tries to run a process through the CreateProcess Windows API. |
noFeedback
|
0 | — | async | If the captureOutput flag is set, set this flag to avoid writing the output to the Shogun Post log file. |
title
|
1 | string | hide, dos | If the type of process being launched is a console application, this flag sets the title of the console window. It has no effect on GUI processes. |
Return value
string
Returns the captured output of the command if the -captureOutput flag is specified.
Examples
// Show how to use the -dos option, which will delete a file on disk. // Even though Shogun Post deals with file paths using forward // slashes, the DOS command interpreter expects back-slashes. // This means that you will need to use double-back slashes in // the string you pass to the command since the back-slash is an // "escape character" in Shogun Post, meaning it is used in // combination with the next character to signify a special value. // In addition, if the file path has a space in it, you will need // to surround it with quotes as in this example here (the same // goes if we didn't specify the -dos flag) system "del \"C:\\PathToSome\\File.dat\"" -dos; // Execute a console application and redirect its output to // the Shogun Post command prompt. system "\"C:\\My\\ConsoleApp.exe\" SomeValue AnotherValue" -captureOutput"; // This launches Notepad. Using the -async flag allows the script // that calls the system command to continue executing. Without it, // Shogun Post would be hung until the user closed the Notepad window. system "notepad.exe C:\\SomeFile.txt" -async;
, multiple selections available,