Running the GoldSim Player in Hidden Mode Using the Command Line

The GoldSim Player provides a command line option that runs the Player in "hidden mode", such that it runs as a background process, and is not actively seen on the desktop. This is useful in cases where you want a separate program to run the Player (without the user being aware that it being run).

This is accomplished using a -h (for "hide") flag. The flag can be used in combination with any existing command line flags (such as -r for run, -x for exit, -getdb to run a database import). Note, however, that if the hide flag is specified, the Player will automatically exit after execution. In other words, it is not necessary to include the -x flag if the hide flag is used. An example command line instruction with the -h flag is given below:

GSPlayer.exe -h -r -sv Model1_Results.gsp Model1.gsp

This would open the model file "Model1.gsp", run it, save it to "Model1_Result.gsp", and exit, all in the background (i.e., such that the fact that the Player ran will not be apparent to the user).

In hidden mode, error messages and Interrupt Element messages are suppressed (i.e. not shown). However, an alternative command line flag, -hl (or -hide-log), is available that instructs the Player to generate a log file to which any such messages will be written. If the run is executed successfully, the log file will contain the text ‘SUCCESS!’. Otherwise, it will contain the text ‘ERROR!’ followed by details of the error. The log file name, by default, is the name of the Player file with the .gsp extension replaced by a .log extension. Alternatively, a log file name may be provided (inside double quotation marks if it includes spaces) following the -hl (or -hide-log) flag. An example is shown below.

GSPlayer.exe -hide-log "Model1 Errors.log" -r Model1.gsp

The following points should also be noted:

Note that the Player process returns an exit code upon exiting when running in hidden mode. A 0 code indicates no errors were identified. A code of 1 or greater indicates an error.

Exit Code Comments
0 Successful execution.
1 An error occurred while preparing or running the simulation. This includes any errors while checking the model, importing data from external sources, running the model.
2 GoldSim Player was unable to create, open or write to the log file. Program execution may or may not have been successful.
4 File I/O Error: GoldSim Player was unable to load the model file.
5 Generic Error Processing Shell Command: this is a fall back for cases when an error occurred but cannot be traced back to the a specific origin.
9 An error occurred during post-simulation export of model results.
10 GoldSim Player was unable to obtain write access to spreadsheet file required for saving intermediate model output data.

The exit code can be queried using an IF statement in the batch file as shown in the example below:

if errorlevel 1 ( echo ERROR while executing GoldSim [code:%errorlevel%])

In this example, if the error code is 1 or greater, the error code will be written to the console.