Using the Command-Line Interface

You can start CODESYS.exe from the command line with the following switches and options.

Syntax:

\ <folder>CODESYS.exe> --<switch or option>

Note

Paths or option parameters must be written inside straight quotation marks when they contain spaces, dashes, or slash marks.

Switch --culture (language of the user interface)

In the command line, include this switch after the development system call in order to set the language of the user interface.

Syntax:

--culture=<culture>

<Culture>: Typical language codes are as follows: de, en, fr, it, es, zh-CHS.

Example

Starting CODESYS with the user interface in English:

CODESYS.exe --culture=en

See also

Switch --profile (CODESYS profile)

In the command line, include this switch after the development system call in order to start CODESYS with a specific profile. When you start CODESYS without this switch, the Select Profile opens.

Syntax:

--profile="<profile name>"

<profile name>: You have to specify the profile name exactly as it is displayed in the Help ‣ About splash screen of the development system or in the start menu on your computer.

Example

CODESYS.exe --culture=de --profile="\ CODESYS V3.6"

See also

Switch --compare (start project comparison)

In the command line, include this switch after the development system call in order to perform a comparison between two CODESYS projects. Type the path of the project file after the switch and then the path of the reference project. CODESYS starts and opens the Project Comparison - Differences view.

Syntax:

--compare="<path of project file>" "<path of reference project file>"

Example

CODESYS.exe --compare "D:\\proj\\project1.project" "D:\\proj\\project2.project"

See also

Option --project (CODESYS project)

In the command line, include this option after the development system call in order to open the given project in CODESYS.

Syntax:

--project="<path of project file>"

<path of project file>: File path of project

Example

Open the test project:

CODESYS.exe --culture=de --project="D:\\projects\\test.project"

See also

Option --projectarchive (CODESYS project archive)

In the command line, include this option after the development system call in order to extract the given project archive and open the project in CODESYS.

Syntax:

--projectarchive="<path of project archive file>"

<path of project archive file>: File path of project archive

Example

Extract the test.projectarchive and open the project in the development system:

CODESYS.exe --projectarchive="D:\\projects\\test.projectarchive"

See also

Option --runscript (execute script)

In the command line, include this option after the development system call in order to execute a given script file from CODESYS.

Command Line Options for –runscript
--runscript="<scriptfile>.py"

CODESYS executes the <scriptfile>.py script file at startup.

You must provide the complete path of the script file.

--scriptargs:'<arg1> <arg2> ... <argn>' Use this option with the --runscript option. As a result, the parameters <arg1> ... <argn> are passed to the script. The arguments are forwarded to the Python variable sys.argv.
--noUI

Use this option with the --runscript option.

The CODESYS user interface is not opened.CODESYS prints all errors, warnings, compiler reports, and command-line messages generated from the script. The script messages (1: Severity Text) can be separated from other messages (2: Severity FatalError, Error, Warning, Information) with the “>” operator.

--enablescripttracing Use this option with the --runscript option. As a result, each command of the script file is shown in the output.
--textPrompts

Use this option with the --noUI option. As a result, message service methods and default dialogs are output in the command line for user input.

If you do not specify --textPrompts, then all message service prompts are confirmed automatically with default values.

scriptdebugger {="<debugger>"}

Use this option with the --runscript option. It sets IronPython in debug mode so that external debuggers can be used to debug Python scripts. The following values are defined for <debugger> (uppercase/lowercase is irrelevant).

  • auto: Automatically detects if a debugger is included in every script for the current process. At this time, only .NET-based debuggers can be detected automatically. A detected debugger overwrites the --enablescripttracing flag.

  • .NET: Activates debugging for .NET-based debuggers, such as “Python Tools for Visual Studio” (PTVS) and SharpDevelop. With this option, a debugger can also be included in running scripts, as opposed to “auto”.

    Note: This is currently the default value when --scriptdebugger is used without providing a value.

  • disabled: Deactivates debugging and automatic detection.

  • script: Switches the IronPython script engine to debug mode for activating the debugging for set-trace debuggers. The script itself must connect to and disconnect from the debugger.

  • tracing: Activates the simple integrated script tracing mode and deactivates the automatic detection (same as the --scripttracing switch).

  • $absolute_path.py$: Absolute path to a Python script that initiates the connection to a Python-based debugger. The IronPython script engine is switched to debug mode for allowing the debugging for set-trace debuggers. This script is executed one time during the initialization and should define the following non-parameterized functions:

    scriptdebuggersetup is executed immediately before executing the user script to establish the connection to the debugger.

    scriptdebuggershutdown is called immediately after executing the user script or when the script engine is downloaded and should close the connection to the debugger.

Examples of using transfer parameters in script files with ‘sys.argv’

start /b /wait CODESYS.exe
--runscript="D:\Script\ArgvAnd__main__Test.py"
--scriptargs:'username password 3.14 "path=\"C:\temp\\"'

Script file: ArgvAnd__main__Test.py

from __future__ import print_function
import sys
print("sys.argv: ", len(sys.argv), " elements:")

for arg in sys.argv:
    print(" - ", arg)
print()
print("__name__: ", __name__)

Output result: stdout:

sys.argv: 6 elements:
- D:\TestScripts\ArgvAnd__main__Test.py
- username
- password
- 3.14
- path= "C:temp"
__name__: __main__

For more information about the __name__ global variable, see the Python documentation.

Examples of the message output

start /b /wait CODESYS.exe --runscript="D:\Script\AmpelTest.py" --noUI 1>ScriptMessages.txt

CODESYS forwards all messages that are generated by the script to the ScriptMessages.txt file. Other messages are printed to the command line.

start /b /wait CODESYS.exe --runscript="D:\Script\AmpelTest.py" --noUI 2>NUL

CODESYS suppresses all messages, except for script messages. The script messages are printed to the command line.

Example of option –scriptdebugger

The following initdebug.py script was tested successfully with pydevd-based debuggers, such as PyDev / LiClipse and PyCharm. To use this script, start CODESYS with the following command line:

--profile="Fanta Development Build" --scriptdebugger="D:\test\charmdebug\initdebug.py"

File: initdebug.py:

from _future_ import print_function
from _future_ import unicode_literals
import sys
sys.path.append(r"D:\test\Env2\Lib\site-packages\pycharm-debug.egg")
import pydevd
def scriptdebuggersetup():
pydevd.settrace('localhost', port=51234, stdoutToServer=True, stderrToServer=True)
def scriptdebuggershutdown():
pydevd.stoptrace()

See also

Option --ignorewhitespace

In the command line, add this option to the development system call after the option --compare <project1> <project2> in order to ignore spaces in the project comparison. Note that semantically relevant spaces, for example in STRING literals, are still taken into account.

Syntax

--compare="<path of project file>" "<path of reference project file>" --ignorewhitespace="true"|"false"

Example

CODESYS.exe --compare "D:\\proj\\project1.project" "D:\\proj\\project2.project" --ignorewhitespace="true"

See also

Option --ignorecomments

In the command line, add this option to the development system call after the option --compare <project1> <project2> in order to ignore comments in the project comparison.

Syntax:

--compare="<path of project file>" "<path of reference project file>" --ignorecomments="true"|"false"

Example

CODESYS.exe --compare "D:\\proj\\project1.project" "D:\\proj\\project2.project" --ignorecomments="true"

See also

Option --ignoreproperties

In the command line, add this option to the development system call to ignore object attributes (access privileges, compile settings, directories, bitmaps, etc.) in the project comparison.

Syntax:

--compare="<path of project file>" "<path of reference project file>" --ignoreproperties="true"|"false"

Example

CODESYS.exe --compare "D:\\proj\\project1.project" "D:\\proj\\project2.project" --ignoreproperties="true"

See also

Option --skipunlicensedplugins (component license missing)

In the command line, add this option to the development system call to skip the prompt whether unlicensed components should still be loaded. If so, then CODESYS does not load these components by implication.

Example

CODESYS.exe –skipunlicensedplugins

See also: Managing Packages and Licenses