Command Line Interface

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

Syntax:

<path 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 to set the language of the user interface.

Syntax:

--culture=<culture>

<culture>: Typical language codes include 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 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 must type 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 (project compare)

In the command line, include this switch after the development system call to compare two CODESYS projects. First, type the project file path after the switch. Then, type the path reference project. CODESYS starts and opens the Project Compare - 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 the 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 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 the project archive

Example

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

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

See also

Option --runscript (execute scripts)

In the command line, include this option after the development system call 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 switch to transfer the <arg1> ... <argn> parameter to the script. The arguments are forwarded to the Python variable sys.argv.
--noUI

Use this option with the --runscript switch.

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 switch to display every command in hte script file.
--textPrompts

Use this option with the --noUI switch to print message service methods and default dialogs in the command line for user input.

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

scriptdebugger {="<debugger>"}

Use this option with the --runscript switch to switch IronPython to debugging mode for Python scripts to use external debuggers in error checking. 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”.

    Please 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 debugging mode for activating the debugging for set-trace debuggers. This 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 debugging 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 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, refer to the Python documentation.

Examples of 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, which 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> to ignore spaces in the project comparison. Please 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

Example

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

See also

Option --ignorecomments

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

Syntax:

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

Example

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

See also

Opiton --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

Example

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

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 loads these components by implication.

Example

CODESYS.exe –skipunlicensedplugins

See also: Managing Packages and Licenses