Most parts of the opsi software are open source.
The parts of opsi that are not open source are still under a co-funded development. Information about these parts can be found here:
opsi cofunding projects

The predefined virtual system folders which can be used are at Windows:desktop, sendto, startmenu, startup, programs, desktopdirectory,common_startmenu, common_programs, common_startup, common_desktopdirectory
and at Linux:common_programs,common_startup,desktop, startup

The predefined virtual system folders:desktop, sendto, startmenu, startup, programs, desktopdirectory
are pointing to the folders of the user that the script is running.
If you use it in a userLoginScript with the opsi User Profile Management extension these virtual folders point to the folder of the user that just had logged in.

shortcut defaults to empty. // since 4.11.6.7shortcut may be a combination of [shift,alt,ctrl] (not case sensitiv) divided by ' , '-,+ an a Key or a Virtual Key Code.
The Key is a letter (A - Z) or a numeral (0 - 9). All other Keys must be given by there Virtual Key Code identifier. To get these identifier (as well as the allowed combinations) just use the following helper program:http://download.uib.de/opsi4.0/helper/showkeys.exe

importLib <string expr> ; import library // since 4.12.0.0
<string expr> : <file name>[.<file extension>][::<function name>]
If no .<file extension> is given .opsiscript is used as default.
If no ::<function name> is given, all function from the given file will be imported.

<file name> is:

A complete path to an existing file. [W/L]

A existing file in %ScriptPath% [W/L]

A file in %opsiScriptHelperPath%\lib [W]
Is equivalent to: %ProgramFiles32Dir%\opsi.org\opsiScriptHelper\lib

A existing file in %ScriptPath%/../lib [W/L]

A existing file in %WinstDir%\lib [W] or /usr/share/opsi-script/lib [L]

The tests for the location of the <file name> are done in the order above. opsi-script uses the first file it finds that has a matching name.

scriptWasExecutedBefore : boolean - is true if saved and running productversion-packageversion are identical //since 4.11.2.1
see also : [scriptWasExecutedBefore]

Chapter 3. Introduction

The open source program opsi-winst/opsi-script serves in the context of opsi – open pc server integration (cf. www.opsi.org) – as the central function for initiating and performing the automatic software installation. It may also be used stand alone as a tool for setup programs for any piece of software.

opsi-winst/opsi-script is basically an interpreter for a specific, rather simple script language which can be used to express all relevant elements of a software installation.

A software installation that is described by a opsi-winst/opsi-script script and performed by executing the script has several advantages compared with installations that are managed by a group of shell commands (e. g. copy etc.):

opsi-winst/opsi-script can log very thoroughly all operations of the installation process. The support team can check the log files, and then easily detect when errors occurred or other problematic circumstances unfold.

Copy actions can be configured with a great variety of options if existing files should be overwritten

Especially, it may be configured to copy files depending on their internal version.

There are different modes to write to the Windows registry:

overwrite existing values

write only when no value exists

append a value to an existing value.

The Windows registry can be patched for all users which exist on a work station (including the default user, which is used as prototype for further users).

There is a sophisticated syntax for an integrated patching of XML configuration files.

Chapter 4. Using opsi-script on Linux

4.1. Introduction

As of version 4.11.4 there is a Linux port of opsi-winst with the name opsi-script.

Conditionally to the progress on porting and the differences between Linux and Windows not all functionalities are available for both operating systems.

In the following section the availability is marked as:

[W/L] may be used on Windows and Linux as well

[W] Windows only

[L] Linux only

4.2. Important differences and hints

opsi-script is a GUI application which needs a running and accessible X Windows.

opsi-script-nogui is a command line version which can run without any GUI.

At Linux the parameter delimiter is not "/" but "-". So instead of calling opsi-winst /help you should call opsi-script -help at Linux.

4.3. opsi-script path

According to the Linux Filesystem Hierachy Standard the files that belong to opsi-script are not at one place but distributed around the system. So here an overview where to find which part:

executable programs:/usr/bin/opsi-script/usr/bin/opsi-script-nogui

log files directories:
if running with root privileges: /var/log/opsi-script
if not running with root privileges: /tmp

4.4. Path handling in opsi-script

As of version 4.11.4 for all functions that expect a path as argument, the path string is converted to a valid path for the actual operating system. This means that all path delimiters will be set OS specific. For example a path string like /home/opsiproduct\myproduct\CLIENT_DATA will be on Linux converted to /home/opsiproduct/myproduct/CLIENT_DATA. Therefore it is not possible to handle files that have a backslash in their name.

Chapter 5. Start and Command Line Options

Since version 4.11.3, the opsi-winst/opsi-script program contains a manifest with the statement:<requestedExecutionLevel level="highestAvailable" />. This means that if opsi-winst/opsi-script is called on an NT6 OS by an Administrator, then it will run as an elevated process. If opsi-winst/opsi-script is called with normal user privileges, then it will run with the privileges of this user.

opsi-winst/opsi-script can be started with different sets of parameters depending on context and purpose of use.

At Linux the parameter delimiter is not "/" but "-". So instead of using opsi-winst /help like you would do at Windows you should use at Linux opsi-script -help.

Some explanations:

Default name of the log file is an Windows c:\opsi.org\log\opsi-script.log

The parameter string, which is marked by the option /parameter, is accessible for every called opsi-winst/opsi-script script (via the string function ParamStr).

Explanations to (2) and (3) :

If option /batch is used, then opsi-winst/opsi-script shows only its "batch surface" offering no user dialogs. By option /silent event the batch surface is suppressed. Without using option /batch we get into the interactive mode where script file and log file can be chosen interactively (mainly for testing purposes).

The winstconfigfilepath parameter which is designated by /histofile refers to a file in ini file format that holds the (in interactive mode) last used script file names. The dialogue surface presents a list box that presents these file names for choosing the next file to interpret. If winstconfigfilepath ends with "\" it is assumed to be a directory name and WINST.INI serves as file name.

Explanations to (4):

The default for clientid is the full qualified computer name

When called with option /allloginscripts or /loginscriptsopsi-winst/opsi-script can do configurations for the logged in user (particularly in a Roaming Profile context). This is a cofunding feature - you need to buy it in order to use it.
See at the opsi-manual for more information about User Profile Management.

By option /silent the batch surface is suppressed.

The not interactive mode is implied.

5.1. Log File and Paths

The default log file name is opsi-script.log.
You may find up to 8 Backup copys of old log files: from opsi-script_0.log until opsi-script_8.log.

The log file encoding is UTF-8.

By default log files are written at Windows into the directory c:\opsi.org\log which opsi-winst/opsi-script tries to create. If opsi-winst/opsi-script has no access to this directory it uses the user-TEMP directory.

At Linux:
If running as root (default): /var/log/opsi-script
If running as any other user: /tmp

The log file name and location will be overwritten via the specific command line option.

In the case, that opsi-winst/opsi-script executes a script in /batch mode and with a specified (and working) usercontext, the default logging path is the opsi/tmp in the appdata directory of the user. This will be overwritten by an explicit given log path.

5.2. Central configuration via opsi Configs (Host Parameter)

Using opsi Configs (Host-Parameter) you may now change the logging:

opsi-script.global.debug_prog : boolean
If false log messages that are only relevant for debugging the opsi-script program it self are not written excepting Warnings and Errors.
Default: false
This will keep the log files smaller because you will find only messages that are relevant for understanding what your script is doing.
The adjustment of all log messages to this new way is in progress and will be take a while since all (about 1700) log calls inside the code are reviewed.

opsi-script.global.debug_lib : boolean
If false log messages from defined functions that are imported from external library files will be suppressed excepting Warnings and Errors.
Default: false

opsi-script.global.default_loglevel : intstr
Sets (overrides) the default log level that is imlemented inside the opsi-script code. This config has no effect on scripts where the loglevel is explicit set by a setLogLevel statement.
Default: 6
see also [SetLogLevel]

opsi-script.global.force_min_loglevel : intstr
Forces a minimal log level.
This can be used while debugging or development to set temporary and for selected clients a higher log level wthout changing the script.
Default: 0
see also [SetLogLevel]

opsi-script.global.ScriptErrorMessages : boolean
This config overwrites the opsi-script internal default value for ScriptErrorMessages if opsi-script is running in the context of the opsi web service.
If the value is true, syntactical errors trigger a pop up window with some informations on the error. This is in productive environments no good idea. Therefore the default value for this config is false.
Inside a script the statement ScriptErrorMessages may be used to set this different from the defaults.
Default: false
see also : [ScriptErrorMessages]

opsi-script.global.w10bitlockersuspendonreboot : boolean
If this config is true and the script has a reboot request it will be checked
if the Operating System is Windows >= 10 and bitlocker is active (encryption > 0%) on the system drive (e.g. c:). if all these conditions are given, opsi-scrpt calls via powershell a suspend-bilocker.
(https://docs.microsoft.com/en-us/powershell/module/bitlocker/suspend-bitlocker?view=win10-ps)
This causes, that after the reboot no password input is needed. This method leads to a loss of security:
"Suspension of BitLocker does not mean that BitLocker decrypts data on the volume. Instead, suspension makes key used to decrypt the data available to everyone in the clear."
Default: false

Chapter 6. Additional Configurations

6.1. Central Logging of Error Messages

If the opsi-winst/opsi-script running in opsi web service mode, it sends the log file via opsi web service to the opsi server.

6.2. Skinnable opsi-winst/opsi-script [W/L]

Since version 3.6 the opsi-winst/opsi-script GUI can be customized. The elements for customizing are to be found in the winstskin subdirectory of the opsi-winst/opsi-script directory. The configuration file for customization is skin.ini.

Since version 4.11.3.5 the opsi-winst searches the skin directory in the following order (directory with the first skin.ini to be found wins):

%WinstDir%\..\custom\winstskin

%WinstDir%\winstskin

With the Command SetSkinDirectory the SkinDirectory to be used can be defined in the script. If the path specified is empty or not valid, the default path will be used.

6.3. opsi-winst/opsi-script encoding [W/L]

The default encoding for a script is the encoding of the running operating system. So for example one script will be interpreted on a Greek windows system as encoded with cp1253 on a German windows system as cp1252 and under Linux as UTF-8.

encoding=<encoding>
Since Version 4.11.4.1 it is possible to define the encoding in the script. This may be done in the main script and in the sub scripts and includes as well. You have to give the command:encoding=<encoding>
This command can be at any position in the code (Even before [actions]). As <encoding> you may give one of the following values:

Chapter 7. The opsi-winst/opsi-script Script

On principle: opsi-winst/opsi-script is an interpreter for a specific, easy to use scripting language which is tailored for the requirements of software installations. A script should be an integrated description, and a means of control, for the installation of one piece of software.

The following section sketches the structure of a opsi-winst/opsi-script script. The purpose is to identify the book marks of a script: in which way we to have to look into it, to understand its processing.

All elements shall be described more in detail in the further section. The purpose then will be to show how scripts can be modified or developed.

7.1. An Example

opsi-winst/opsi-script scripts are roughly derived from .INI files. They are composed of sections, which are marked by a title (the section name) which is written in brackets [].

Schematically a opsi-winst/opsi-script script looks like this one (here with a check which operating system is installed):

7.2. Primary and Secondary Subprograms of a opsi-winst/opsi-script script

The script as a whole serves as a program, an instruction for an installation process. Therefore each of its sections can be seen as a a subprogram (or "procedure" or "method"). The script is a collection of subprograms.

The human reader as well as an interpreting software has to know at which element in this collection reading must start.

Execution of a opsi-winst/opsi-script script begins with working on the [Actions] section. All other sections are called as subroutines. This process is only recursive for Sub sections: Sub sections have the same syntax as Actions sections and may contain calls for further subroutines.

Note

If a script is run as userLoginScript and it contains a section [ProfileActions], so the script interpretation will be started at the ProfleActions section.

This gives reason to make the distinction between primary and secondary subprograms:

The primary or general control sections comprise

the Actions section

Sub sections (0 to n subroutines called by the Actions section which are syntactical and logical extensions of the calling section).

the ProfileActions section, which will be interpreted in different ways according to the script mode (Machine/Login).

The procedural logic of the script is determined by the sequence of calls in these sections.

The secondary or specific sections can be called from any primary section but have a different syntax. The syntax is derived from the functional requirements and library conditions and conventions for the specific purposes. Therefore no further section can be called from a secondary section.

7.3. String Expressions in a opsi-winst/opsi-script Script

Textual values (string values) in the primary sections can be given in different ways:

A value can be directly cited, mostly by writing in into (double) citation marks. Examples:"Installation of Mozilla""n:\home\user name"

A value can be given by a String variable or a String constant, that "contains" the value:
The variable $MsVersion$ may stand for "6.1" – if it has been assigned beforehand with this value.

A function retrieves or calculates a value by some internal procedure. E. g.
EnvVar ("Username")
fetches a value from the system environment, in this case the value of the environment variable Username. Functions may have any number of parameters, including zero:GetMsVersionInfo
On a win7 system, this function call yields the value "6.1" (not as with a variable this values has to be produced at every call again).

A value can be constructed by an additive expression, where string values and partial expressions are concatenated - theoretically "plus" can be seen as a function of two parameters:$Home$ + "\mail"

There is no analogous way of using string expressions in the secondary sections. They follow there domain specific syntax. e.g. for copying commands similar to the windows command line copy command. Up to this moment it is no escape syntax implemented for transporting primary section logic into secondary sections.

The only way to transport string values into secondary sections is the use of the names of variables and constants as value container in these sections. Lets have a closer look at the variables and constants of a opsi-winst/opsi-script script:

Chapter 8. Definition and Use of Variables and Constants in a opsi-winst/opsi-script Script

8.1. General

In a opsi-winst/opsi-script script, variables and constants appear as "words", that are interpreted by opsi-winst/opsi-script and "contain" values. "Words" are sequences of characters consisting of letters, numbers and some special characters (in particular ".", "-", "_", "$", "%"), but not blanks, but no brackets, parentheses, or operator signs ("+") .

opsi-winst/opsi-script variables and constants are not case-sensitive.

There exist the following types of variables or constants:

Global text constants, shortly constants,
contain values which are present by the opsi-winst/opsi-script program and cannot be changed in a script. Before interpreting the script opsi-winst/opsi-script replaces each occurrence of the pure constant name with its value in the whole script (textual substitution).
An example will make this clear:
The constant %ScriptPath% is the predefined name of the location where opsi-winst/opsi-script found and read the script that it just executes. This location may be, e.g., p:\product. Then we have to write"%ScriptPath%"
in the script when we want do get the value"p:\product".

observe the citations marks which include the constant delimiter.

Text or String variables, shortly variables,
have an appearance very much like any (String) variables in a common programming language. They must be declared by a DefVar statement before they can be used. In primary sections, values can be assigned to variables (once ore more times). They can be used as elements in composed expressions (like addition of strings) or as function arguments.
But they freeze in a secondary section to a phenomenon that behaves like a constant. There, they appear as a non-syntactical foreign element. Their value is fixed and is inserted by textual substitution for their pure names (when a section is called, whereas the textual substitution for real constants take place before starting the execution of the whole script).

Stringlist variables
are declared by a DefStringList statement. In primary sections they can be used for many purposes, e.g. collecting strings, manipulating strings, building sections.

In detail:

8.2. Global Text Constants

Scripts shall work in a different contexts without manual changes. The contexts can be characterized by system values as OS version or certain paths. opsi-winst/opsi-script introduces such values as constants into the script.

8.2.1. Usage

The fundamental characteristics of a text constant is the way how the values which it represents come intro the script interpretation process:

The name of the constant, that is the pure sequences of chars, is substituted by its fixed value in the whole script before starting the script execution.

The replacement does not take into account any syntactical context in which the name possibly occur (exactly like with variables in secondary sections).

8.2.2. Example

opsi-winst/opsi-script implements constants %ScriptPath% for the location of the momentarily interpreted script and %System% for the name of the windows system directory. The following (Files) subsection defines a command that copies all files from the script directory to the windows system directory:

/AllNtUserProfiles directory constants [W]

In Files sections that are called with option /AllNtUserProfiles there is a pseudo variable%UserProfileDir%
When the section is executed for each user that exists on a work station this variable represents the name of the profile directory of the user just treated.

%CurrentProfileDir% // since 4.11.2.1
may be used instead of the older %UserProfileDir% in order to have Files-sections which may be used also for userLoginScripts.

8.2.4. opsi-winst/opsi-script Path and Directory [W/L]

%opsiScriptHelperPath%
Corresponds to: %ProgramFiles32Dir%\opsi.org\opsiScriptHelper
Path in which the help program, libraries, and items needed for script execution could be installed.
Since 4.11.3.2

%ScriptPath% or %ScriptDir% : represents the path of the current opsi-winst/opsi-script script (without closing backslash). Using this variable we can build path and file names in scripts that are relative to the location of the script. So, everything can be copied, called from the new place, and all works as before.

%ScriptDrive% : The drive where the just executed opsi-winst/opsi-script script is located (including the colon).

%opsiserviceUser% : The user ID for which there is a connection to the opsi service. If running in opsi service context this is usally the clint FQDN used by opsi.

%opsiservicePassword% : The user password used for the connection to the opsi service. The password is eliminated when logging by the standard opsi-winst/opsi-script logging functions.

%installingProdName%: The productid of the product that is actually installed via call by the opsi-service. Empty if the Script ist not started by the opsi-service.

%installingProdVersion%: A String combinated from <productversion>-<packageversion> for the product that is actually installed via call by the opsi-service. Empty if the Script ist not started by the opsi-service.

%installingProduct% : (Deprecated) The name (productId) of the product for which the service has called the running script. In case that there the script is not run via the service the String is empty.

8.3. String (or Text) Variables [W/L]

8.3.1. Declaration

String variables must be declared before they can be used. The syntax for the declaration reads

DefVar <variable name>

e.g.

DefVar $MsVersion$

Explanation:

Variable names do not necessarily start or end with a dollar sign, but this is recommended as a convention to understand their functioning in secondary sections.

Variables can only be declared in primary sections (Actions section, sub sections and ProfileActions).

The declaration should not depend on a condition. That is it should not placed into a branch of an if – else statement. Otherwise, it could happen that the DefVar statement is not executed for a variable, but an evaluation of the variable is tried in some if clause (such producing a syntax error).
The variables are initialized with an empty string ("").

Recommendation:

The first and last letter of the name should be $

Define all variables at the beginning of the script

8.3.2. Value Assignment

As it is appropriate for a variable, it can take on one value resp. a series of values while a script is progressing. The values are assigned by statements with syntax

8.3.3. Use of variables in String expressions

In primary sections of a opsi-winst/opsi-script script, a variable "holds" a value. When it is declared it is initialized with the empty String "". When a new value is assigned to it via the set command, it represents this value.

In a primary section a variable can replace any String expression resp. can be a component of a String expression, e.g.

Set $MailLocation$ = $Home$ + "\mail"

In a primary section the variable name denotes an object that represents a string, If we add the variable we mean that the underlying string shall be added somehow.

This representational chain is shortcut in a secondary section. Just the variable name now stands for the string.

8.3.4. Secondary vs. primary sections

When a secondary section is loaded and opsi-winst/opsi-script starts its interpretation the sequence of chars of a variable name is directly replaced by the value of the variable.

In a primary section we may now express the directory
"n:\home\user name\mail\backup"
by$MailLocation$ + "\backup"

The same directory has to be designated in a secondary section as:"$MailLocation$\backup"

A fundamental difference between the thinking of variables in primary vs. secondary sections is that, in a primary section, we can form an assignment expression like$MailLocation$ = $MailLocation$ + "\backup"

As usual, this means that $MailLocation$ first has some initial value and takes on a new value by adding some string to the initial value. The reference from the variable is dynamic, and may have a history.

In a secondary section any such expression would be worthless (and eventually wrong), since $MailLocation$ is bound to be replaced by some fixed string (at all occurrences virtually in the same moment).

8.4. Stringlist Variables [W/L]

Variables for string lists must be declared in a DefStringList statement, e.g.

Chapter 9. Syntax and Meaning of Primary Sections of a opsi-winst/opsi-script Script [W/L]

As shortly presented in chapter 4 the Actions section of a script can be regarded as a the main method of the opsi-winst/opsi-script script and describes the global processing sequence. It may call subroutines - the Sub sections which may then recursively call Sub sections themselves.

The following sections explain syntax and use of the primary sections of a opsi-winst/opsi-script script.

9.1. Primary Sections [W/L]

There are possibly three kinds of primary sections in a script

an Initial section (may be omitted),

an Action section,

any number of Sub sections

an ProfileActions section

Initial and Action section are syntactically equivalent (but Initial has to keep the first place). By convention, in the Initial section some parametrizations of the script execution (e.g. the loglevel) are made. The Action section can be regarded as the main program in a opsi-winst/opsi-script script. It contains the sequence of actions that are controlled by the script.

Sub sections are as well syntactically equivalent. But they are a called from the Action section. Then, they can call themselves Sub sections.

A Sub section is determined by creating a name that begins with "Sub", e.g. Sub_InstallBrowser. By writing its name in the Action section we produce a call to the Sub section. The meaning of this call is defined by the content of the section in the script that begins with the bracketed name, in the example [Sub_InstallBrowser]

Note

Subsections of second and higher order cannot host internal sections. Instead, their procedure calls must refer to sections defined in the main script file or defined as external sections (cf. Section 9.16, “Subprogram Calls”).

Caution

If (nested) sub sections are externalized to external files, the called sections has to be in that file where they are called from. According to the complexity of the script they may sometimes have to be placed also in the main file.

9.2. Parametrizing opsi-winst/opsi-script [W/L]

9.2.1. Specification of Logging Level [W/L]

Caution

The old function LogLevel= is deprecated since opsi-winst/opsi-script version 4.10.3. For backward compatibility reasons Loglevels ste by this old function will be increased by 4 before they are used.

There are two syntactical variants for specifying the logging level:

SetLogLevel = <number>

SetLogLevel = <String expression>
I.e. the number can be given as an integer value or as a string expression (cf. section 6.3). In the second case, opsi-winst/opsi-script tries to evaluate the string expression as a number.
There exist ten levels from 0 up to 9.

9.2.2. Required opsi-winst Version [W/L]

makes opsi-winst/opsi-script check if the desired version state is given. Otherwise an error message windows pops up.

This feature exists since opsi-winst/opsi-script version 4.3. For an earlier version, the statement is unknown, and the statement itsself is a syntactical error which will be indicated by syntax error window (cf. the following section). Therefore the statement can be used independently of the currently used opsi-winst/opsi-script version as long as the required version is at least version 4.3.

9.2.3. Reacting on Errors [W/L]

There are two kinds of errors which are treated in different ways:

illegal statements which cannot be interpreted by opsi-winst/opsi-script (syntactical errors),

failing statements which cannot be executed because of external, objective reasons (execution errors).

In principal, syntactical errors are indicated by a pop up window for immediate correction, execution errors are logged in a log file to be analysed later.

The behaviour of opsi-winst/opsi-script when it recognizes a syntactical error is defined by the configuration statement

ScriptErrorMessages = <boolean value>
If the value is true (default), syntactical errors trigger a pop up window with some informations on the error.
The boolean value may be true or false. Delimiters on or off can be used as well.
Default=true
see also: [opsi-script-configs_ScriptErrorMessages]

FatalOnSyntaxError = <boolean value>

true = (default) If a syntax error occurs, then the script execution will be stopped and the script result will be set to failed. Also, the message Syntax Error will be passed to the opsi-server.

false = If a syntax error occurs, then the script execution will not be stopped and the script result will be set to success.

In either case above, the syntax error will be logged as Critical.
In either case above, the error counter will be increased by 1.
Since 4.11.3.2
In older versions there was no logging of syntax errors, no increase of error counter, and the result was always set to success.

FatalOnRuntimeError = <boolean value>
A Runtime Error is an script logic error that leads to an forbidden or impossible operation. An Example: You try to get the 5th string from a string list that have only 3 elements.

true = If a runtime error occurs, then the script execution will be stopped and the script result will be set to failed. Also, the message Runtime Error will be passed to the opsi-server.

false = (default) If a runtime error occurs, then the script execution will not be stopped and the script result will be set to success. The runtime error will be logged as Error and the error counter will be increased by 1.
Since 4.11.4.3

There two configuration options for execution errors.

ExitOnError = <boolean value>
This statement defines if the script execution shall terminate when an error occurs. If the value is true or yes the program will stop execution, otherwise errors are just logged (default).

TraceMode = <boolean value>
In TraceMode (default false) every log file entry will additionally be shown in message window with an O.K. button.

9.2.4. Staying On Top [W]

StayOnTop = <Wahrheitswert>

With StayOnTop = true (or = on) we request, that - in batch mode - the opsi-winst/opsi-script window be on top on the windows which share the screen. That means it should be visible in the "foreground" as long as no other window having the same status wins.

Caution

According to the system manual the value cannot be changed while the program is running. But it seems that we can give a new value to it once.

StayOnTop has default false in order to avoid that some other process raises an error message which eventually can not be seen if opsi-winst/opsi-script keeps staying on top.

9.3. Show window mode / Skin / Activity [W/L]

SetSkinDirectory <skindir> // [W/L]
Sets the skin directory to use and loads the skin.
If this command is used wit an empty or invalid path, the default skin dir is used. The default skin dir %WinstDir%\winstskin.

Then the variable $Meta_citation$ will exactly contain the complete sequence of chars that follows the colon after "EscapeString" (including the blank). Such, $Meta_citation$ will contain the complete statement: Set $citation$ = 'he said "Yes"'

9.4.5. String Functions which Return the OS Type

GetOS : string [W/L]
The function tells which type of operating system is running.
We recommend to use GetMsVersionInfo.
GetOS` returns one of the following values:
"Windows_NT" (including Windows 2000 to Windows 10)
"Linux"

GetNtVersion [W]
Deprecated - please use GetMsVersionInfo.
A Windows NT operating system is characterized by a the Windows type number and a subtype number. GetNtVersion returns the precise subtype name. Possible values are
"NT3"
"NT4"
"Win2k" (Windows 5.0)
"WinXP" (Windows 5.1)
"Windows Vista" (Windows 6)
If the NT operating system has higher versions as 6 or there are version not explicitly known the function returns "Win NT" and the complete version number (5.2, … resp. 6.0 ..) . E.g. for Windows Server 2003 R2 Enterprise Edition, we get
"Win NT 5.2"
If the operating system is no Windows NT system the function returns the error value
"No OS of Windows NT type"

GetMsVersionInfo [W]
returns for systems of type Windows NT the Microsoft version info as indicated by the API, e.g. a Windows XP system produces the result
"5.1"

Table 9.1. Windows Versions

GetMsVersionInfo

Windows Version

5.0

Windows 2000

5.1

Windows XP (Home, Prof)

5.2

XP 64 Bit, 2003, Home Server, 2003 R2

6.0

Vista, 2008

6.1

Windows 7, 2008 R2

6.2

Windows 8, 2012

6.3

Windows 8.1, 2012 R2

10.0

Windows 10

see also GetMsVersionMap

getLinuxDistroType : string [L]
returns the type of the running Linux distribution an can be used to determine which general syntax we have to use. It may return one of the following values

debian (Debian / Ubuntu → use apt-get)

redhat (RedHat / CentOs → use yum)

suse (→ use zypper)
(see getLinuxVersionMap) [L]

GetSystemType : string [W/L]
checks the installed Windows OS if it can be assumed that the system is 64 Bit. In this case the value is 64 Bit System otherwise x86 System.

The function reads and returns the momentary value of a system environment variable.

E.g., we can retrieve which user is logged in by EnvVar ("Username").
ParamStr
The function passes the the parameter string of the opsi-winst/opsi-script command line i.e. the command line parameter which is indicated by /parameter. If there is no such parameter ParamStr returns the empty string.
GetLastExitCode
returns the exit code (also called ErroLevel) of the last Winbatch call.
GetUserSID(<Windows Username>)
returns the SID for a given user (possibly with domain prefix in the form
DOMAIN\USER).

EnvVar (<environment variable>) : string [W/L] [W/L]
The function reads and returns the momentary value of a system environment variable. E.g., we can retrieve which user is logged in by EnvVar ("Username").

ParamStr [W/L]
The function passes the the parameter string of the opsi-winst/opsi-script command line i.e. the command line parameter which is indicated by /parameter. If there is no such parameter ParamStr returns the empty string.

GetLastExitCode [W/L]
returns the exit code (also called ErroLevel) of the last Winbatch call.

GetUserSID(<Windows Username>) [W]
returns the SID for a given user (possibly with domain prefix in the form
DOMAIN\USER).

GetUsercontext [W]
returns the string which was given to the opsi-winst/opsi-script by the optional parameter /usercontext. IF this parameter was not userd the returned string is empty.

getRegistryValue (<keystr>, <varstr> [, <access str>]) : string //since 4.12.0.16 [W]
tries to use <keystr> as Registry key and open it and read there the variable <varstr> and return the value of this variable as a string.
If there is no registry key <keystr> or the variable <varstr> does not exist the function produces a warning message in the log file and returns the empty string.
If <varstr> is an empty string, the default entry of the key will be returned.
By Default the registry access mode is sysnative. Using the optional third parameter <access str>, the access mode can be explicitly given. In this case it has to be one of the following values: 32bit, sysnative, 64bit.
(see also: Chapter 64 Bit)

GetRegistrystringvalue("[key] var") : string [W]
tries to interpret the passed String value as an expression of format[KEY] X
Then, the function tries to open the registry key KEY, and, in case it succeeds, to read and return the String value that belongs to the registry variable name X .
see also : [getRegistryValue]

RegString(<string>)
is useful for transforming path names into the format which is used in the Windows registry. That is, any backslash is duplicated. E. g.,

RegString ("c:\windows\system\")

yields"c:\\windows\\system\\"

9.4.8. Reading Values from ini files [W/L]

For historical reasons, there are three functions for reading values from configuration files which have ini file format. Since opsi 3.0 the specific product properties are retrieved from the opsi configuration demon (that may fetch it from a configuration file or from any other backend data container).

In detail:
Ini file format means that the file is a text file and is composed of "sections" each containing key value pairs:

[section1]
Varname1=Value1
Varname2=Value2
...
[section2]
...

The most general function reads the value belonging to some key in some section of some ini file. Any parameter can be given as an arbitrary String expression:

GetValueFromInifile ( file, section, key, default value ) : string [W/L]
The function tries to open the ini file FILE, retrieve the requested SECTION and find the value belonging to the specified KEY which the function will return. If any of these operations fail DEFAULTVALUE is returned.

The second function borrows its syntax from the ini file format itself, and may sometimes be easier to use. But since this syntax turns complicated in more general circumstances it is deprecated. The syntax reads:

9.4.9. Reading Product Properties [W/L]

GetProductProperty ( <PropertyName>, <DefaultValue>)
where $PropertyName$ and $DefaultValue$ are String expressions.
If opsi-winst/opsi-script is connected to the opsi configuration service the product property is retrieved from the service.
If the opsi-winst/opsi-script is not connected to the service or for other reasons the the call fails, the given <DefaultValue> will be returned.

The product properties can be used to configure variants of an installation.

E.g. the opsi UltraVNC network viewer installation may be configured using the options

viewer = <yes> | <no>

policy = <factory_default> |

The installation script branches according to the chosen values for these options which can be retrieved by

GetConfidentialProductProperty ( <PropertyName>, <DefaultValue>) //since 4.11.5.2
like GetProductProperty but handles the resulting value as confidential string.
Useful for getting passwords without logging. see also SetConfidential

IniVar(<PropertyName>)
(deprecated: use GetProductProperty)

9.4.10. Retrieving Data from etc/hosts [W/L]

GetHostsName(<string>)
returns the host name to a given IP address as it is declared in the local hosts file. If the operating system is "Windows_NT" (according to environment variable OS) "%systemroot%\system32\drivers\etc\" is assumed as host file location, otherwise "C:\Windows\".

GetHostsAddr(<string>)
tells the IP address to a given host or alias name.

9.4.11. String Handling [W/L]

ExtractFilePath (<path>) : string [W/L]
interprets the passed String value as file or path name and returns the path part (the string up to the last "\", including it).

takeString (<index>, <list>) : string [W/L]
returns from a string list <list> the string with the index <index>.
Often used in combination with splitstring:
takeString(<index>, splitString(<string1>, <string2>)
(see also Section 9.5, “String List Functions and String List Processing [W/L]”).
The result is produced by slicing <string1> where each slice is delimited by an occurrence of <string2>, and then taking the slice with index <index> (where counting starts with 0).

Example:

takeString(3, splitString ("\\server\share\directory", "\"))

returns "share",
the given string slpitted at "\" returns the string list:
Index 0 - "" (empty string), because there is nothing before the first "\"
Index 1 - "" (empty string), because there is nothing before the second "\"
Index 2 - "server"
Index 3 - "share"
Index 4 - "directory"

takestring counts downward, if the index is negative, starting with the number of elements. Therefore,

getIndexFromListByContaining(<list> : stringlist,<search string> : string`)` : <number> : string //since 4.12.0.13 [W/L]
Returns a string that holds the index of the first string in <list> which contains <search string>.
Retruns a empty string if no matching string is found.
The check is performed case-insensitive.

takeFirstStringContaining(<list>,<search string>) : string [W/L]
returns the first string from <list> which contains <search string>.
Retruns a empty string if no matching string is found.
see also : [takeFirstStringContaining]

stringReplace(<string>, <oldPattern>, <newPattern>) : string //since 4.11.3 [W/L]
returns a string, which has all occurrences of <oldPattern> replaced with <newPattern> given then input string <string>. The pattern match is case insensitive.

strPos(<string>, <sub string>) : string (numner) //since 4.11.3 [W/L]
returns the first position of <sub string> in <string>. If <sub string> is not found, then "0" is the return value. The function is case sensitive.

strPart(<string>, <start pos>, <number of chars>) : string //since 4.11.3 [W/L]
returns the part of <string> starting with <start pos> and include the next <number of chars> chars. If there are fewer than <number of chars> after <start pos>, then the returned string will be the rest of the chars after <start pos>.
The counting of chars starts with 1.

unquote(<string>,<quote-string>) : string //since 4.11.2.1 [W/L]
returns the unquoted version of <string>, if <string> is quoted with <quote-string>
Only one char (the first char) of <quote-string> is accepted as a quote char. The leading white spaces are ignored.
see also : [unquote2]

unquote2(<string>,<quote-string>) : string //since 4.11.5.2 [W/L]
Acts like unquote(<string>,<quote-string>) with the following differences:
If <quote-string> contains only one char, so this char will be used as start quote char and end quote char. If <quote-string> contains two chars, so the first char will be used as start quote char and the second char as end quote char. Example: a <quote-string> like "()" will unquote a string like (hello).
The function returns the unchanged <string> if not (start quote char AND end quote char) is found.

HexStrToDecStr (<hexstring>) : string [W/L]
returns the decimal representation of the input string if this was the hexadecimal representation of an integer. Leading chars like 0x or $ will be ignored. In case of a converting error the function returns a empty string.

DecStrToHexStr ( <decstring>, <hexlength>) : string [W/L]
returns a <hexlength> long string with the the hexadecimal representation of <decstring> if this was the decimal representation of an integer. In case of a converting error the function returns a empty string.

GetShortWinPathName(<longpath string>) //since 4.11.5.2 [W]
Returns the short path (8.3) from <longpath string>. If ther is no short path for <longpath string>, so you will get an empty string.
Example: GetShortWinPathName("C:\Program Files (x86)") returns "C:\PROGRA~2"

CompareDotSeparatedNumbers(<string1>, <string2>) : string [W/L]
compares two strings of the form <number>[.<number>[.<number>[.<number>]]]
It returns "0" if the strings are equal, "1" if <string1> is higher and "-1" if <string1> is lower than <string2>.
see also: CompareDotSeparatedNumbers(<str1>,<relation str>,<str2>) : [CompareDotSeparatedNumbers_bool]

comment: Testing:
message CompareDotSeparatedNumbers
Set $string1$ = "1.2.3.4.5"
The value of the variable "$string1$" is now: "1.2.3.4.5"
Set $string2$ = "1.2.3.4.5"
The value of the variable "$string2$" is now: "1.2.3.4.5"
Set $ConstTest$ = "0"
The value of the variable "$ConstTest$" is now: "0"
Set $CompValue$ = CompareDotSeparatedNumbers($string1$, $string2$)
The value of the variable "$CompValue$" is now: "0"
If
$ConstTest$ = $CompValue$ <<< result true
($ConstTest$ = $CompValue$) <<< result true
Then
comment: passed
comment: 1.2.3.4.5 is equal to 1.2.3.4.5
Else
EndIf
Set $string1$ = "1.2.31.4.5"
The value of the variable "$string1$" is now: "1.2.31.4.5"
Set $string2$ = "1.2.13.4.5"
The value of the variable "$string2$" is now: "1.2.13.4.5"
Set $ConstTest$ = "1"
The value of the variable "$ConstTest$" is now: "1"
Set $CompValue$ = CompareDotSeparatedNumbers($string1$, $string2$)
The value of the variable "$CompValue$" is now: "1"
If
$ConstTest$ = $CompValue$ <<< result true
($ConstTest$ = $CompValue$) <<< result true
Then
comment: passed
comment: 1.2.31.4.5 is higher then 1.2.13.4.5
Else
EndIf
Set $string1$ = "1.2.3.4.5"
The value of the variable "$string1$" is now: "1.2.3.4.5"
Set $string2$ = "1.2.13.4.5"
The value of the variable "$string2$" is now: "1.2.13.4.5"
Set $ConstTest$ = "-1"
The value of the variable "$ConstTest$" is now: "-1"
Set $CompValue$ = CompareDotSeparatedNumbers($string1$, $string2$)
The value of the variable "$CompValue$" is now: "-1"
If
$ConstTest$ = $CompValue$ <<< result true
($ConstTest$ = $CompValue$) <<< result true
Then
comment: passed
comment: 1.2.3.4.5 is lower then 1.2.13.4.5
Else
EndIf

CompareDotSeparatedStrings(<string1>, <string2>) : string [W/L]
compares two strings of the form <string>.<string>[.<string>[.<string>]]
It returns "0" if the strings are equal, "1" if <string1> is higher and "-1" if <string1> is lower than <string2>. The function is not case sensitive.
see also : [CompareDotSeparatedStrings_bool]

comment: Testing:
message CompareDotSeparatedStrings
Set $string1$ = "1.a.b.c.3"
The value of the variable "$string1$" is now: "1.a.b.c.3"
Set $string2$ = "1.a.b.c.3"
The value of the variable "$string2$" is now: "1.a.b.c.3"
Set $ConstTest$ = "0"
The value of the variable "$ConstTest$" is now: "0"
Set $CompValue$ = CompareDotSeparatedStrings($string1$, $string2$)
The value of the variable "$CompValue$" is now: "0"
If
$ConstTest$ = $CompValue$ <<< result true
($ConstTest$ = $CompValue$) <<< result true
Then
comment: passed
comment: 1.a.b.c.3 is equal to 1.a.b.c.3
Else
EndIf
Set $string1$ = "1.a.b.c.3"
The value of the variable "$string1$" is now: "1.a.b.c.3"
Set $string2$ = "1.A.B.C.3"
The value of the variable "$string2$" is now: "1.A.B.C.3"
Set $ConstTest$ = "0"
The value of the variable "$ConstTest$" is now: "0"
Set $CompValue$ = CompareDotSeparatedStrings($string1$, $string2$)
The value of the variable "$CompValue$" is now: "0"
If
$ConstTest$ = $CompValue$ <<< result true
($ConstTest$ = $CompValue$) <<< result true
Then
comment: passed
comment: 1.a.b.c.3 is equal to 1.A.B.C.3
Else
EndIf
Set $string1$ = "1.a.cb.c.3"
The value of the variable "$string1$" is now: "1.a.cb.c.3"
Set $string2$ = "1.a.b.c.3"
The value of the variable "$string2$" is now: "1.a.b.c.3"
Set $ConstTest$ = "1"
The value of the variable "$ConstTest$" is now: "1"
Set $CompValue$ = CompareDotSeparatedStrings($string1$, $string2$)
The value of the variable "$CompValue$" is now: "1"
If
$ConstTest$ = $CompValue$ <<< result true
($ConstTest$ = $CompValue$) <<< result true
Then
comment: passed
comment: 1.a.cb.c.3 is higher then 1.a.b.c.3
Else
EndIf
Set $string1$ = "1.a.ab.c.3"
The value of the variable "$string1$" is now: "1.a.ab.c.3"
Set $string2$ = "1.a.b.c.3"
The value of the variable "$string2$" is now: "1.a.b.c.3"
Set $ConstTest$ = "-1"
The value of the variable "$ConstTest$" is now: "-1"
Set $CompValue$ = CompareDotSeparatedStrings($string1$, $string2$)
The value of the variable "$CompValue$" is now: "-1"
If
$ConstTest$ = $CompValue$ <<< result true
($ConstTest$ = $CompValue$) <<< result true
Then
comment: passed
comment: 1.a.ab.c.3 is lower then 1.a.b.c.3
Else
EndIf
Set $string1$ = "1.2.13.4.5"
The value of the variable "$string1$" is now: "1.2.13.4.5"
Set $string2$ = "1.2.3.4.5"
The value of the variable "$string2$" is now: "1.2.3.4.5"
Set $ConstTest$ = "-1"
The value of the variable "$ConstTest$" is now: "-1"
Set $CompValue$ = CompareDotSeparatedStrings($string1$, $string2$)
The value of the variable "$CompValue$" is now: "-1"
If
$ConstTest$ = $CompValue$ <<< result true
($ConstTest$ = $CompValue$) <<< result true
Then
comment: passed
comment: 1.2.13.4.5 is lower then 1.2.3.4.5
comment: using CompareDotSeparatedStrings give wrong results on numbers
Else
EndIf
Set $string1$ = "1.2.3.4.5"
The value of the variable "$string1$" is now: "1.2.3.4.5"
Set $string2$ = "1.2.13.4.5"
The value of the variable "$string2$" is now: "1.2.13.4.5"
Set $ConstTest$ = "1"
The value of the variable "$ConstTest$" is now: "1"
Set $CompValue$ = CompareDotSeparatedStrings($string1$, $string2$)
The value of the variable "$CompValue$" is now: "1"
If
$ConstTest$ = $CompValue$ <<< result true
($ConstTest$ = $CompValue$) <<< result true
Then
comment: passed
comment: 1.2.3.4.5 is higher then 1.2.13.4.5
comment: using CompareDotSeparatedStrings give wrong results on numbers
Else
EndIf

getDiffTimeSec [W/L]
returns a string with the integer number of seconds since the last call of marktime.
Available since 4.11.3.1

timeStampAsFloatStr : string (Floating Number - format: days.decimal days) //since 4.11.6 [W/L]
Gives Date and Time from now as string that contains a decimal number in the format: days.decimal days. This Format make it easier to claculate time differences.

SidToName(<well known sid>) [W]
returns a string with the localized name of the group with the <well known sid>. For example, if <well known sid> is equal to S-1-5-32-544 then SidToName returns Administrators.
Available since 4.11.3.1

GetMyIpByTarget(<target ip addr>) [W/L]
returns a list of interface IP-addresses, which are trying to reach the operating system at <target ip addr>. This function returns a value that is safer than the constant %IPAddress%.
Since Version 4.11.3.1
Example:

getLastExitCode : string (exitcode) [W/L]
returns a string that contains the value of the exitcode of the last process called by a WinBatch / DosBatch / ExecWith section.
When using a DosBatch or ExecWith section, you will normally get the exitcode from the interpreter that was called. To get the exitcode of your script, you have to define it explicitly.

9.4.13. (String-) Functions for Licence Management [W/L]

DemandLicenseKey(`poolId [, productId [,windowsSoftwareId]])`
asks the opsi service via the function getAndAssignSoftwareLicenseKey for a reservation of a licence for the client.
The pool from which the licences is taken may be explicitly given by its ID or is identified via an associated product ID or Windows Software Id (possible, if these associations are defined in the licences configuration).poolId, productId, windowsSoftwareId are Strings (resp. String expressions).
If no poolId is explicitly given, the first parameter has to be an empty String "". The same procedure is done with other not explicit given Ids.
The function returns the licence key that is taken from the pool.

FreeLicense(`poolId [, productId [,windowsSoftwareId]]])`
asks the opsi service via the function freeSoftwareLicense to release the current licence reservation.
The syntax is analogous to the syntax for DemandLicenseKey

Example:

DefVar $opsiresult$
set $opsiresult$ = FreeLicense("pool_office2007")

$opsiresult$ becomes the empty String, if no error occurred, and, if an error occurred, the error info text.

9.4.14. Retrieving Error Infos from Service Calls [W/L]

getLastServiceErrorClass
returns, as its name says, the class name of the error information of the last service call. If the last service call did not produce an error the function returns the value "None".

getLastServiceErrorMessage
returns the message String of the last error information resp. "None".
Since the message String is more likely to be changed, it is recommended to base script logic on the class name.

9.5. String List Functions and String List Processing [W/L]

A String list (or a String list value) is a sequence of String values. For this kind of values we have the variable of type String list. They are defined by the statement

DefStringList <VarName>

A String list value may be assigned to String list variable:

Set <VarName> = <StringListValue>

String list values can be given only as results of String expressions. There are many ways to create or capture String lists, and many options for processing them, often yielding new String lists. They are presented in the following subsections.

For the following examples we declare a String list variable $list1$:

DefStringList $list1$

If we refer to variables named like String0, StringVal, .. it is meant that these represent any String expressions.

We start with a special and rather useful kind of String lists: maps – also called hashes or associative arrays – which consist of a lines of the form KEY=VALUE. In fact, each map should establish a function which associates a VALUE to a KEY, and any KEY should occur at most once as the first part of a line (whereas different KEY’s may be associated with identical 'VALUE parts).

9.5.1. Info Maps

getHWBiosInfoMap //since 4.11.4 [L/W]
get hardware information from BIOS and writes them to hash map string list.
There are the folowing keys: (example):

9.5.2. Producing String Lists from Strings [W/L]

createStringList (<string0>, <string1> ,… ) : stringlist [W/L]
forms a String list from the values of the listed String expressions. For example, by

set $list1$ = createStringList ('a','b', 'c', 'd')

we get a list of the first four letters of the alphabet.

The following two functions produce a String list by splitting some string:
splitString (<string1>, <string2>) : stringlist [W/L]
generates the list of partial strings of <string1> (including empty strings) before resp. between the occurences of <string2>. E.g.,

set $list1$ = splitString ("\\server\share\directory", "\")

defines the list"", "", "server", "share", "directory"
If the given string is in the list of confidential strings, so the resulting string parts will also be added to the list of confidential strings.

produces the list"Status", "Lokal", "Remote", "Netzwerk"
no matter how many blanks or tabs constitute the white space between the words.
If the given string is in the list of confidential strings, so the resulting string parts will also be added to the list of confidential strings.

9.5.3. Loading Lines of a Text File into a String List

loadTextFile (<file name>) : stringlist [W/L]
reads the file <file name> and generates the string list, that contains all lines of the file.

loadTextFileWithEncoding( <file name> , <encoding>) : stringlist [W/L]
reads the file <file name> and generates the string list, that contains all lines of the file. The string will be reencoded from <encoding> to system encoding.

loadUnicodeTextFile (<file name>) : stringlist [W]
reads the unicode text file <file name> and generates the string list, that contains all lines of the file.
By this call, the strings are converted into the system default 8 bit code.

getSectionNames(<ini-file>) : stringlist [W/L]
interprets the specified file as an inifile, looks for list of all lines of form[<SectionName>]
and returns the pure section names (without brackets).

composeString (<string list>, <Link>) : string [W/L]
With this function, the elements of any String list can be glued to one another, mediated by a "glue string".
E.g. if $list1$ represents the list a, b, c, d, e
by

$line$ = composeString ($list1$, " | ")

we assign the value "a | b | c | d | e". to $line$.

takeString (<index>, <list>) : string [W/L]
For example, if $list1$ represents the list of the first five letters of the alphabet, using

takeFirstStringContaining(<list>,<search string>) : string [W/L]
returns the first string of the list which contains the <search string>.
Returns an empty string if no matching string was found.

getValue(<key string>, <hash string list> ) : string [W/L]
This function tries to interpret a String list as list of lines of the form
key=value
It looks for the first line, where the string <key> is followed by the equality sign, and returns the remainder of the line (the value, the string that starts after the equality sign). If there is no fitting line, it returns the string NULL.
The function is required for using the GetLocaleInfoMap and getFileVersionMap string list functions (cf. Section 9.5.1, “Info Maps”).

getValueBySeparator(<key string>,<separator string>,<hash string list> ) : string //since 4.11.2.1 [W/L]
works like getValue but you have to give the <separator string> so that can also work with hashes likekey:value

getValueFromFile(<key string>, <file name>) : string //since 4.11.4.4 [W/L]
Searches in <file name> for a key/value pair with key <key string> and separator string = and returns the value. If <key string> is not found it returns an empty string.

getValueFromFileBySeparator(<key string>,<separator string>,<file name>) : string //since 4.11.4.4 [W/L]
Searches in <file name> for a key/value pair with key <key string> and separator string <separator string> and returns the value. If <key string> is not found it returns an empty string.

9.5.5. Producing String Lists from opsi-winst Sections [W/L]

getOutStreamFromSection (<dos section name>) : stringlist (output) [W/L]
invokes the section and – at this moment implemented only for DosInAnIcon (ShellInAnIcon),ExecWith and ExecPython calls – captures the output to standard out and standard error of the invoked commands writing them into a string list. For example:

getReturnListFromSection (`section name)` [W/L]
For some section types - at this moment implemented only for XMLPatch sections and opsiServiceCall sections - there is a specific return statement which yields some result of the execution of the section (assumed to be of String list type).
E.g. we may use the statement

to get a specific knot list of the XML file mimetypes.rdf. (More info to XMLPatch sections at Section 10.7, “XMLPatch Sections [W]” in this manual).
Or the list of opsi clients is produced by the reference to a opsi service call:

9.5.6. Stringlists from the registry [W]

getRegistryKeyList32(<regkey>) : stringlist [W]
Returns a stringlist with the names of all keys within <regkey>.
32 Bit mode (with redirection). Available since 4.11.3

getRegistryKeyList64(<regkey>) : stringlist
Returns a stringlist with the names of all keys within <regkey>.
64 Bit mode (without redirection). Available since 4.11.3

getRegistryKeyListSysnative(<regkey>) : stringlist
Returns a stringlist with the names of all keys within <regkey>.
Mode (redirection) depends on the architecture of the OS. Available since 4.11.3

getRegistryVarList32(<regkey>) : stringlist
Returns a stringlist with the names of all value entries associated with key <regkey>.
32 Bit mode (with redirection). Available since 4.11.3

getRegistryVarList64(<regkey>) : stringlist
Returns a stringlist with the names of all value entries associated with key <regkey>.
64 Bit mode (without redirection). Available since 4.11.3

getRegistryVarListSysnative(<regkey>) : stringlist
Returns a stringlist with the names of all value entries associated with key <regkey>.
Mode (redirection) depends on the architecture of the OS. Available since 4.11.3

getRegistryVarMap32(<regkey>) : stringlist
Provides a map of all name=value pairs in the given registry key <regkey>.
32 Bit Mode (with redirection). Since 4.11.3

getRegistryVarMap64(<regkey>) : stringlist
Provides a map of all name=value pairs in the given registry key <regkey>.
64 Bit Mode (with redirection). Since 4.11.3

getRegistryVarMapSysnative(<regkey>) : stringlist
Provides a map of all name=value pairs in the given registry key <regkey>.
Mode depend on the architecture of the operating system. Since 4.11.3

Example:
At first, we create entries in the registry with the following example code:

9.5.7. Stringlists from the Product Properties [W/L]

getProductPropertyList(<propname>,<default value>)
returns a stringlist of values that are referred to by the multivalue product property <propname>. If there is no connection to the opsi server, then the resulting stringlist contains only <default value>.
If you call the function GetProductProperty with a multivalue property, then you will get the selected values in a comma-separated string format. This will lead to problems if the returned values contain any comma chars that are not meant to be parsed.<default value> decribes the return value if no connection to the opsi-server is available. If <default value> is a string expression this string is the first element of the returned list. Since 4.11.5.6 <default value> may also be a string list expression.
Available since 4.11.3
Example:

GetProcessList : stringlist //since 4.11.1.2; gives list of exename;pid;dom/user [W/L]
Provides a list of running processes.
For each process you get one line with a ; separated list of the following process information:

we get the partial list b, c, d . Begin index as well as end index have to be interpreted as the index of the first and last included list elements. The counting starts with 0.
Default start index is 0, default end index is the index of the last element of the list.
Therefore, (for the above defined list1) the command

set $list1$ = getSubList(1 : , $list$)

yields the list b, c, d, e.

set $list1$ = getSubList(:, $list$)

produces a copy of the original list.
It is possible to count backwards in order to determine the last index:

set $list1$ = getSubList(1 : -1, $list$)

defines the list of elements starting with the first and ending with the last element of the list – in the above example we again get list b, c, d,e.

set $list1$ = getSubList(1 : -2, $list$)

defines the list of elements starting with the first and ending with the second to last element of the list – in the above example we get list b, c, d.

Since version 4.12.0.35 you may beside numbers also use string expressions: strings, string variables or string functions.

getSubListByMatch (<search string>, <target list>) :stringlist //since 4.12.0.14 [W/L]
returns the part of <target list> where the string matches with <search string>.
The check is performed case-insensitive.

getSubListByMatch (<search list>, <target list>) :stringlist //since 4.12.0.14 [W/L]
returns the part of <target list> where the string matches with one of the strings of <search list>.
The check is performed case-insensitive.

getSubListByContaining (<search list>, <target list>) :stringlist //since 4.12.0.14 [W/L]
returns the part of <target list> where the string contains with one of the strings of <search list>.
The check is performed case-insensitive.

getSubListByKey (<search string>, <target list>) :stringlist //since 4.12.0.14 [W/L]
returns the part of <target list> where the string starts with <search string>=.
The check is performed case-insensitive.

getSubListByKey (<search list>, <target list>) :stringlist //since 4.12.0.14 [W/L]
returns the part of the key/value <target list> where the key is one of the strings of <search list>.
The check is performed case-insensitive.

getKeyList (<list>) :stringlist //since 4.12.0.14 [W/L]
returns from the the key/value list <list> (in the format key=value) the list of keys.
Is an entry in <list> not in the format key=vakue, the complete string will be part of the result list.

takeFirstStringContaining(<list>,<search string>) : string [W/L]
returns the first string from <list> which contains <search string>.
Return en empty string if <search string> is not found.
see also : [takeFirstStringContaining]

removeFromListByContaining(<search list>, <target list>) : stringlist //since 4.11.5.1 [W/L]
Returns a copy of <target list> where all lines are removed that contains a string out of <search list>. The match to <search list> is case insensitiv.

Examples:

File "%Scriptpath%\test-files\encoding\10lines.txt" is:

line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8
line 9
line 10

removeFromListByMatch(<searchstring>,<target list>) : stringlist //since 4.11.6 [W/L]
Returns a copy of <target list> where all lines are removed that exactly match a line out of <search list>. The match to <search sting> is case insensitiv.
see also : [removeFromListByContaining_str]
see also : [removeFromListByContaining_list]

setStringInListAtIndex(<newstring>,<list>,<indexstr>) : stringlist //since 4.11.6 [W/L]
Replaces in the existing stringlist <list> the existing string at <index> by <newstring>. If <index> is to hight, <newstring> will be appended. In case of an error the result is an empty string list.
see also : [takeString]

9.5.10. Iterating through String Lists [W/L]

An important usage of string lists is based on the possibility that the script runs through all elements of a list executing some operation on each string element.

The syntax to define this repetition is:

for %s% in <list> do <one statement | sub section>

This expression locally defines a string variable %s% that takes one by one the values of the list elements.
<one statement> can be any single statement that can exist in a primary section or (and most interestingly) it may be a subsection call. The locally defined iteration index %s% exists in the whole context of statement, in particular in the subsection if statement is a subsection call.

Caution

The replacement mechanism for %s% always works like that for constants: The name of the variable is replaced by the element values. If we iterate through a list a,b,c and the iteration index is named %s%, we get for %s% one by one a, b, c – not the String values. To reproduce the original list elements we have to enclose %s% in citation marks.

9.7. Calculating with numbers [W/L]

opsi-winst scripts do not have a special type of varibles for numbers. But there are some functions to help calculating with numbers.

calculate(<arithmetic string expression>) : string (number)
this string function calculates the arithemtic expression of the string <str> and returns the rounded result as a string.
Internally the calculations are done with real numbers. This function acceptsthe operators +, -, *, / and round brackets (,).
In case of an error, an empty string is returned and the error counter is incremented. If the passed string contains any characters other than numbers, valid operators and brackets, this results in an error.
If the second operand is missing, the first operand is also taken as the second operand and vice versa: 5+ = 10 ; 5* = 25. So the strings that are used to assemble the argument should be validated by the funktion isNumber.
(since version 4.11.3.5)

For more examples refer to the product opsi-script-test
at the section $Flag_calculate$ = "on"

9.8. Process and Script Related functions [W/L]

waitForPackageLock(<seconds timeout string>,<bool should we kill>) : bool //since 4.11.6.1 [L]
Returns true if the Linux package system is not locked by an other process. If it is locked, it waits <seconds timeout string> to get the lock. If the timeout is reached and <bool should we kill> is true than the locking process is killed but using this feature ist not recommended.

The first line of the script makes sure that we get no exit code = 0 if the script fails with an exception. The last line gives the exit code of previous command back.
The architecture of the called powershell.exe is sysnative by default.
Using the optional second parameter <access str> you may change this default. In this case it has to be one of the following values: 32bit, sysnative, 64bit.
(see also: Chapter 64 Bit)
By Windows default the powershell has the execution policy Retricted which do not allow to run any unsigned scripts. In order to run scripts the powershellCall function does by default the following: The current execution-policy is backuped and the execution-policy is set to RemoteSigned. Then the script will be executed and finally the execution-policy is restored. This default behaviour may be switched off by setting the optional third parameter <policy bool str> to "false".
If the powershellCall function is called where a stringlist is expected it returns a stringlist that contains the output of <commandstr>.

powershellCall (<commandstr> [,<access str>=sysnative [,<policy bool str>=true]]) : noresult //since 4.12.0.16 [W]
see [powershellCall_list]
The function powershellCall may also be called where no result is expected.

Example:

powershellCall('Get-Process -ProcessName "opsi*"')

powershellCall (<commandstr> [,<access str>=sysnative [,<policy bool str>=true]]) : string (exitcode) //since 4.12.0.16 [W]
see [powershellCall_list]
If the powershellCall function is called where a string is expected it returns a string that contains the exit code of the executed script.

In fact processCall is internal a winbatch call, so all the winbatch modifiers are also allowed for processCall

/LetThemGo
This is the contrary to /WaitOnClose. It is used if opsi-winst/opsi-script shall proceed while the started processes run in their own threads.

/TimeOutSeconds <seconds>
A timeout setting. After waiting <seconds>, opsi-winst/opsi-script will end the process.
Since version 4.11.3, /TimeOutSeconds may be used without a waiting condition (e.g. /WaitForProcessEnding) but not in combination with /WaitSeconds.
Since version 4.11.4.6 the time progress from start until timeout is displayed by the progressbar.

/WaitSeconds [number of seconds]
If a call includes the parameter /WaitSeconds [number of seconds], then opsi-winst/opsi-script is waiting for [number of seconds] before proceeding. In the default configuration, we also wait for any programs that are currently running to finish. If we combine the parameter /WaitSeconds with the option /LetThemGo, then opsi-winst/opsi-script continues processing after the waiting time is finished.

/WaitForProcessEnding <program name>
Waits for the process called <program name> to end.
Should be combined with /TimeOutSeconds.

/32Bit //since 4.11.3.5 [W]
This is the default. The paths within the section are assumed to be 32 bit pathes.
Example: c:\windows\system32\regedit.exe calls (even when running on a 64 bit system) the 32 bit regedit.exe.

/64Bit //since 4.11.3.5 [W]
The paths within the section are assumed to be 64 bit paths.
Example: c:\windows\system32\regedit.exe executes (running on a 64 bit system) the 64 bit regedit.exe.

/SysNative //since 4.11.3.5 [W]
The paths within the section are assigned according to the OS architecture interpretiert.
Example: c:\windows\system32\regedit.exe running on a 64bit system calls the 64 bit regedit.exe and running on a 32 bit system the 32 bit regedit.exe.

9.9. Special Commands [W/L]

Killtask <process name> ` : noresult` [W/L]
tries to stop all processes that execute the program named by the string expression.
E.g.

killtask "winword.exe"

ChangeDirectory <directory> ` : noresult` //since 4.11.2.6 [W/L]
Set the given directory as working directory of the opsi-winst/opsi-script. Affects all subsequent actions (e.g. winbatch sections) and will be reset at the end of a script.
Beispiel :

ChangeDirectory "%SCRIPTPATH%\programm"

UpdateEnvironment //since 4.11.5.1 [W]
Sends Windows the signal to reload the environment values from the registry.
This statement may be called after any rocess that may have changed the environment (e.g. Registry section or setup program).
Even if the program that runs after the opsi-script get the new environment, the next process that is started (via DosBatch or Winbatch) from this opsi-script instance will still inherit the old environment. To start a subsequent process with the new environment you have to use winbatch with the /RunElevated parameter.
Works only with NT6 and up.

Example:

comment "Set Environment Variables and check for it ...."
Registry_add_environment /sysnative
UpdateEnvironment
comment "This will not work because the environment is inherited from the running process"
set $list$ = shellCall('set opsi-script-test')
comment "This will work because this new started process will get a new environment"
winbatch_check_environment /RunElevated
if ("42" = getlastExitCode)
comment "passed"
else
comment "failed"
endif
[Registry_add_environment]
openkey [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]
set "opsi-script-test"="deleteme"
[winbatch_check_environment]
"%system%\cmd.exe" /c "if %opsi-script-test%==deleteme exit 42"

sleepSeconds <string> [W/L]
breaks the program execution for <string> seconds. <string> has to represent an Integer Value

markTime [W/L]
sets a time stamp for the current system time and logs it.

diffTime [W/L]
logs the time passed since the last marktime.

9.9.1. Commands to control the logging

comment <string> or comment = <const string> [W/L]
writes the value of the String expression resp. the sequence of characters into the log file.

includelog <file name> <tail size> [<encoding>] //since 4.11.4.1 [W/L]
Includes the file <file name> as a log file, where the last <tail size> lines of the full log are written into this log file. If you start another program that produces a log file, you could see that other program’s log file in the opsi-winst script log using this command.
Since version 4.11.3.2, a negative <tail size> can be given, which will then include the first <tail size> lines from the top of the log file (referred to as Head mode).
Since version 4.11.4.1 there is an optional third parameter which may be used to give the encoding of the file to include. You may give one of the well known encodings described in the encodings chapter. If you give auto opsi-script try to detect the encoding (and may fail). The default is system which means the default OS encoding is used.
Example:

SetConfidential <secret string> [W/L]
This is to prevent confidential information (like passwords) from being logged. In the logfile the confidential information will be replaced by (confidential).
When the loglevel is set to 9, the confidential information will be logged.
(since version 4.11.3.5)

Example:

message "SetConfidential"
SetConfidential "forbidden"
comment "This is a forbidden string"
comment "shown in the should be in the log file: This is a ***(confidential)*** string"

Log:

message SetConfidential
comment: This is a ***(secret)*** string
comment: should be in the log file: This is a ***(confidential)*** string

asConfidential( <secret string expression> ) : string //since 4.12.0.16 [W/L]
This function should be used to get confidentail strings from an other string function without without logging the secret string. The Function work in the following sequence:

Backup the current log level.

Set the log level to Warning. (4)

Resolve the given string expression (for example calling the given string function).

Add the resulting string to the list of confidential strings that should be not logged..

Restore of the inital log level.

Return the resulting string.

Example:

set $ConstTest$ = asConfidential(stringReplace("this is my old secret", "old", "new"))
comment "this is my new secret"
comment "should be in the log file: ***(confidential)*** "

Log:

Set $ConstTest$ = asConfidential(stringReplace("this is my old secret", "old", "new"))
The value of the variable "$ConstTest$" is now: "***(confidential)***"
comment: This is a ***(confidential)*** string
comment: should be in the log file: This is a ***(confidential)*** string----

9.10. Commands for User Information and User Interaction [W/L]

Message <string expression>
bzw.Message = <sequence of characters>
lets opsi-winst/opsi-script display the value of the String expression resp. the sequence of chars in the batch window in the top information line. The text is kept as long as no new message is set.
Example:

Message "Installation von "+$productid$

ShowMessageFile <file name>
interprets the String expression as text file name, tries to read the text and show it in a user information window. Execution stops until the user confirms reading. E.g. by a command like

Pause <string> or Pause = <const string>
display the text given as a String expression or as a sequence of chars in a information window waiting until the user confirms the continuation.

Stop <string> or stop = <const string>
halt program execution if the user confirms it. The String expression resp. the (possibly empty) sequence of chars explain to the user what is supposed to be stopped.

setActionProgress <string> : noresult //since 4.11.3 [W/L]
Transfers <string> as ActionProgress of the running script to the opsi server. By Default the ActionProgress is installing while a script is running. The value of ActionProgreas is displayed at the configed.

9.11. Commands for userLoginScripts / User Profile Management

GetScriptMode //since 4.11.2.1
give one of the possible values Machine,Login:

GetUsercontext //since 4.11.1.2
returns the username in whose context the opsi-winst/opsi-script is just running.
see also : [GetUsercontext]

saveVersionToProfile //since 4.11.2.1
save productversion-packageversion to local profile
It is designed to be used in userLoginScripts.
This command is used in combination with readVersionFromProfile or scriptWasExecutedBefore. It marks that the userLoginScript for this product in this product version and package version was excuted for the actual user. The inrormation is saved at the file "%CurrentAppdataDir%\.opsi.org\userLoginScripts.ini"

readVersionFromProfile //since 4.11.2.1
returns a string with the productversion-packageversion for the running opsi product which was read from local profile. See also: saveVersionToProfile
It is designed to be used in userLoginScripts.

scriptWasExecutedBefore //since 4.11.2.1
This Boolean function scriptWasExecutedBefore checks if there is a version stamp in the profile (like you may do with the readVersionFromProfile command) It returns true if saved and running productversion-packageversion are identical. Then it set a new stamp to the profile (like you may do with the saveVersionToProfile command). So you may just use this single command in a if statement.
It is designed to be used in userLoginScripts.

isLoginScript //since 4.11.2.1
This booleasn function returns true if the script is running as userLoginScript. See also: GetScriptMode
see also : [GetScriptMode]

9.14.1. General Syntax

The syntax of the complete if statement is:if <condition>
<sequence of statements>else
<sequence of statements>endif

The else part may be omitted.

if statements may be nested. That is, in the sequence of statements that depend on an if clause (no matter if inside the if or the else part) another if statement may occur.

<condition> is a <Boolean expression> . A Boolean (or logical) expression can be constructed as a (String) value comparison, by Boolean operators, or by certain function calls which evaluate to true or false. Up to now these Boolean values cannot be explicitly represented in a opsi-winst/opsi-script script).

9.14.2. Boolean Expressions

The String comparison (which is a Boolean expression) has the form<String expression> <comparison sign> <String expression>
where <comparison sign> is one of the signs<<==>=>

String comparisons in opsi-winst/opsi-script are case independent.

Inequality must be expressed by a NOT() expression which is presented below.

There is as well a comparison expression for comparing Strings as (integer) numbers. If any of them cannot be converted to a number an error will be indicated.
This number comparison expression has the same form as the String comparison but for an INT prefix of the comparison sign:<String expression> INT<comparison sign> <String expression>
Such, we can build expressions as

if $Name1$ INT<= $Name2$

or

if $Number1$ INT>= $Number2$

Boolean operators are AND, OR, and NOT() (case does not matter). If b1, b2 and b3 are Boolean expressions the combined expressions
b1 AND b2
b1 OR b2NOT( b3 )
are Boolean expressions as well denoting respectively the conjunction (AND), the disjunction (OR) and the negation (NOT).

A Boolean expression can be enclosed in parentheses (such producing a new Boolean expression with the same value).

The common rules of Boolean operator priority ("and" before "or") are at this moment not implemented. An expression with more than one operator is interpreted from left to right. For clarity, in a Boolean expression that combines AND and OR operators parentheses should be employed, e.g. we should explicitly write
b1 OR (b2 AND b3)
or
(b1 OR b2) AND b3
The second example describes what would be executed if there were no parentheses - whereas the common interpretation would run as the other line indicates.

Boolean operators can be conceived as special Boolean valued functions (the negation operator demonstrates this very clearly).

There are some more Boolean functions implemented. Every call of such a function constitutes a Boolean expression as well:

LineExistsIn (<string>, <file name>) : bool [W/L]
returns true if the text file denoted by <file name> contains a line as specified in the first parameter where each parameter is a String expression. Otherwise (or if the file does not exist) it returns false.

LineBeginning_ExistsIn (<string>, <file name>) : bool [W/L]
returns true if there is line that begins with <string> in the text file denoted by <file name> (each parameter being a string expression). Otherwise (or if the file does not exist) it returns false.

LineContaining_ExistsIn( <string>, <file name> ) : bool [W/L]
returns true if there is line that contains <string> in the text file denoted by <file name> (each parameter being a string expression). Otherwise (or if the file does not exist) it returns false.

XMLAddNamespace(<XMLfilename>, <XMLelementname>, <XMLnamespace>)
inserts a XML namespace definition into the first XML element with the given name (if not existing). It gives back if an insertion took place. (The opsi-winst/opsi-script XML patch section need the definitions of namespace.)
The file must be formatted that an element tag has no line breaks in it.
For an example, cf. cookbook Section 12.7, “Inserting a Name Space Definition Into a XML File”.

HasMinimumSpace(<Laufwerksname>, <Kapazität>)
returns true if at least a capacity capacity is left on drive drivename. capacity as well as drivename syntactically are String expressions. The capacity may be given as a number without unit specification (then interpreted as bytes) or with unit specifications "kB", "MB", or "GB" (case independent).
Example:

CompareDotSeparatedNumbers(<str1>,<relation str>,<str2>) : bool //since 4.11.5.2: [W/L]
compares two strings of the form <number>[.<number>[.<number>[.<number>]]]
by the <relation str> which may be one of [<,⇐,=,>=,>].
see also: string function CompareDotSeparatedNumbers(<string1>, <string2>) : see also : [CompareDotSeparatedNumbers_str]

Set $string1$ = "1.2.30.4.5"
The value of the variable "$string1$" is now: "1.2.30.4.5"
Set $string2$ = "1.20.30.4.5"
The value of the variable "$string2$" is now: "1.20.30.4.5"
If
Checking if "1.2.30.4.5" is "<" than / as "1.20.30.4.5"
CompareDotSeparatedNumbers($string1$, "<", $string2$) <<< result true
Then
comment: passed
Else
EndIf
If
Checking if "1.2.30.4.5" is "<=" than / as "1.20.30.4.5"
CompareDotSeparatedNumbers($string1$, "<=", $string2$) <<< result true
Then
comment: passed
Else
EndIf
If
Checking if "1.2.30.4.5" is "=<" than / as "1.20.30.4.5"
CompareDotSeparatedNumbers($string1$, "=<", $string2$) <<< result true
Then
comment: passed
Else
EndIf
If
Checking if "1.2.30.4.5" is "=" than / as "1.20.30.4.5"
CompareDotSeparatedNumbers($string1$, "=", $string2$) <<< result false
Then
Else
comment: passed
EndIf
If
Checking if "1.2.30.4.5" is ">=" than / as "1.20.30.4.5"
CompareDotSeparatedNumbers($string1$, ">=", $string2$) <<< result false
Then
Else
comment: passed
EndIf
If
Checking if "1.2.30.4.5" is "=>" than / as "1.20.30.4.5"
CompareDotSeparatedNumbers($string1$, "=>", $string2$) <<< result false
Then
Else
comment: passed
EndIf
If
Checking if "1.2.30.4.5" is ">" than / as "1.20.30.4.5"
CompareDotSeparatedNumbers($string1$, ">", $string2$) <<< result false
Then
Else
comment: passed
EndIf

CompareDotSeparatedStrings(<str1>,<relation str>,<str2>) : bool //since 4.11.5.2: [W/L]
compares two strings of the form <str>[.<str>[.<str>[.<str>]]]
by the <relation str> which may be one of [<,⇐,=,>=,>].
see also: string function CompareDotSeparatedStrings(<string1>, <string2>) : [CompareDotSeparatedStrings_str]`

RegKeyExists(<regkey>[,<access str>]) : bool //since 4.12.0.16 [W]
Check if the given string expression <regkey> exists as registry key.
If the registry key was found the result value ist true in all other cases false.
By Default the registry access mode is sysnative. Using the optional second parameter <access str>, the access mode can be explicitly given. In this case it has to be one of the following values: 32bit, sysnative, 64bit.
(see also: Chapter 64 Bit)

RegVarExists(<regkey>, <var str> [,<access str>]) : bool //since 4.12.0.16 [W]
Check if the given string expression <regkey> exists as registry key and if there is a variable with name <var str>.
If both was found the result value ist true in all other cases false.
By Default the registry access mode is sysnative. Using the optional second parameter <access str>, the access mode can be explicitly given. In this case it has to be one of the following values: 32bit, sysnative, 64bit.
(see also: Chapter 64 Bit)

9.15. Include Commands

Caution

Using include commands can lead to confusing code.
Use with caution if you are a beginner.

9.15.1. Include Commands: Syntax

The include_* commands may be used to add external script files to the currently-running script at runtime. The include_* command can include external script files either as an insert (after the current line) or as an append (after the last line). The include commands may be used anywhere in a primary section. The external script files may contain their own include commands.
The include commands are available since version 4.11.3

include_insert <file name>
inserts <file name> after the current line into the running script. So the first line of the included file is the next line that will be executed by opsi-winst/opsi-script.

include_append <file name>
appends the content of <file name> to the running script. This kind of insert is normally used to include sections from a library.

In both cases <file name> is:

A complete path to an existing file. [W/L]

A existing file in %ScriptPath% [W/L]

A file in %opsiScriptHelperPath%\lib [W]
Is equivalent to: %ProgramFiles32Dir%\opsi.org\opsiScriptHelper\lib

A existing file in %ScriptPath%/../lib [W/L]

A existing file in %WinstDir%\lib [W]

The tests for the location of the <file name> are done in the order above. opsi-winst/opsi-script uses the first file it finds that has a matching name.

Since the call to Files_del_tmp_dummy happens inside of include-test1.opsiinc without section_Files_del_tmp_dummy.opsiinc being referenced inside of include-test1.opsiinc, we must call include_append "section_Files_del_tmp_dummy.opsiinc" at the very beginning of our script. Otherwise, opsi-winst will report that Files_del_tmp_dummy is not defined.
The contents of the included file section_Files_del_tmp_dummy.opsiinc are:

[Files_del_tmp_dummy]
del -f "c:\opsi.org\tmp\dummyt.txt"

9.15.2. Include Commands: Library

The following include files are shipped with version 4.11.3, and are located in %WinstDir%\lib:

9.16.1. Syntax of Procedure Calling

This expression may supplemented by one ore ore parameters (procedure type dependent).

That means: A procedure call consists of three main parts.

The first part is the subprogram type specifier.
Examples of type names are Sub (we call a procedure of type sub that is a again a primary section) or Files and WinBatch (calls of special secondary sections). The complete overview of the existing sub program types is given at Section 9.16, “Subprogram Calls”.

The second part determines where and how the lines of sub program are to be found.

The subprogram is a sequence of lines situated in the executed opsi-winst/opsi-script script as another internal section. Then a name (constituted from letters, digits, and some special characters) has to be appended to the type specifier (without space) in order to form an unique section name.sub_install_winXP
orfiles_copy_winXP
Section names are case independent as any other string.

If the type specifier stands alone a String list expression or a String expression is expected. If the expression following the type specifier cannot be resolved as a String list expression (cf. case (3)) it is assumed to be a String expression. The string is then interpreted as a file name. opsi-winst/opsi-script tries to open the file as a text file and interprets its lines as an external section of the specified type.
E.g.sub "p:\install\opsiutils\mainroutine.ins"
tries to execute the lines of mainroutine.ins as statements of a sub section.

The searche rule is:
<file name> may be:

A complete path to an existing file. [W/L]

A existing file in %ScriptPath% [W/L]

A file in %opsiScriptHelperPath%\lib [W]
Is equivalent to: %ProgramFiles32Dir%\opsi.org\opsiScriptHelper\lib

A existing file in %ScriptPath%/../lib [W/L]

A existing file in %WinstDir%\lib [W]

The tests for the location of the <file name> are done in the order above. opsi-winst/opsi-script uses the first file it finds that has a matching name.

If the expression following a pure section type specifier is resolvable as a String list expression the lines of the list are interpreted as the statements of the section.
This mechanism can e.g. be used to load a file that has unicode format and then treat it by the usual mechanisms

registry loadUnicodeTextFile("%scriptpath%/opsiorgkey.reg") /regedit

Syntactically, this line is composed of three main parts:
* registry, the core statement specifying the section type,
* loadUnicodeTextFile(...), a String list expression specifying how to get the lines of a registry section resp. its surrogate.
* /regedit, parametrizing the registry call.

In this example, the call parameter already gives an example for the third part of a subsection call:

The third part of a procedure call comprises type specific call options.

9.17. Controlling Reboot

The command ExitWindows is used to control reboots , shutdown and similar actions which should take place after the opsi-winst/opsi-script it self is terminated. The name of the command and the fact that there is no ExitWindows without modifier has histrical reasons: Working on Windows 3.1 you could exit windows to go back to the DOS level.

ExitWindows /RebootWanted
DEPRECATED: a reboot request is registered which should be executed when all installations requests are treated, and the last script has finished.
In fact, this command is now treated as an ExitWindows /Reboot (since otherwise an installation could fail because a required product is not yet completely installed).

ExitWindows /Reboot
triggers the reboot after opsi-winst/opsi-script has finished the currently treated script.

ExitWindows /ImmediateReboot
breaks the normal execution of a script anywhere inside it. When this command is called opsi-winst/opsi-script runs as directly as possible to its end entailing the system ExitWindows call. In the context of an installed opsi-client-agent it is guaranteed that after rebooting opsi-winst/opsi-script runs again into the script that was aborted. Therefore, the script has to take provisions that the execution continues after the point where it was left the turn before (otherwise we may get an infinite loop …) Cf. the example in this section.

9.17.1. Abort script and keep track of failed installations

If a product installation fails, then this should be signaled to the server.

Due to the fact that there is no automatic method that detects a failed installation, testing for a failed installation has to be done using script commands.

To indicate in a opsi-winst/opsi-script script that the installation is failed we have to call the statement:isFatalError
If this statement is called, then opsi-winst/opsi-script stops the normal execution of the script and sets the product result to failed (otherwise it is success).

Since 4.11.3.2 there is a new variant of this command:

isFatalError <string>
in this case, a short error message string is passed as actionProgress to the opsi-server and displayed in the opsi-configed.
For example, a "fatal error" shall be triggered if there is not as much space left as it is needed for an installation:

It is also possible to stateisFatalError
depending on the number of errors which occured in some critical part of an installation script. In order to do this we initialize the error counting by the command

markErrorNumber
Initialize the error counting.
The number of execution errors which occur after setting the counter can be queried by the the number valued function errorsOccurredSinceMark+

errorsOccurredSinceMark
We can evaluate the result in a numerical comparison condition (that as yet is only implemented for this expression). E. g. we may stateif errorsOccurredSinceMark > 0

For increasing the number of counted errors depending on certain circumstances (that do not directly produce an error) we may use the logError statement.

We may test this by the following script example:

markErrorNumber
; Errors occuring after this mark are counted and
; will possibly be regarded as fatal
logError "test error"
; we write "test error" into the log file
; and increase the number of errors by 1
; for testing, comment out this line
if errorsOccurredSinceMark > 0
; we finish script execution as quick as possible
; and set the product state to "failed"
isFatalError
; but comment writing is not stopped
comment "error occured"
else
; no error occured, lets log this:
comment "no error occured"
endif

isSuccess //since 4.11.3.7 [W/L]
Abort the script as successful.

noUpdateScript //since 4.11.3.7 [W/L]
Do not run an update script after setup even if there is one.

9.18. Local functions [W/L]

9.18.1. Concept

There are a lot possibilities to structure opsi-script code:

sub Sections

sub Sections in external files

include Statements

But all these possibilities are not functional to create reusable external code that can be exchanged between scripts or opsi administrators without problems.
The reason is, that this code is not encapsulated and use global variables.
The defined local functions presented here now solves this problem. With this concept it is possible to write functions that can be collected and maintained in external libraries.
In consequence we will start to build up a central opsi-script library which is maintained by uib and the opsi community.

In order to reach this target we have implemented the following concepts:

Functions with return value:
The functions have a return value which is of the type string or stringlist. Executing such function can be performed wherever a string expression or a stringlist is expected.
Functions with no return value are also allowed and have to be declared as void (since 4.12.0.16).

Freely definable function call parameters:
Parameters can be passed to a function. These parameters are defined when the function is actually declared. The call parameters can be of type string or stringlist.
The call parameters are available as local variables within the function.
The call parameters can be passed as CallByValue or callByReference. CallByValue is the default. That means, if no call method is specified explicitly, then CallByValue will be applied. In the case that CallByValue needs to be explicitly specified, then the keyword val should be used. CallByValue means, that the value of a variable used during the call is copied to the call variable.CallByReference must be specified explicitly using the keyword ref. callByReference means that a connection is created between the variable used as parameter when calling the function and the local variable that represents the call parameter inside the function. Changing the local variable of the call parameter has a direct effect on the variable used during such call.

Local Variables:
A function contains local variables: Implicitly, the call parameters are available as local variables and the variable $result$ which is from the type of the returned value. Further variables can be defined within the function.
All these variables are local, which means that they are only visible within this function. A local variable with the same name of a global variable masks the corresponding global variable within the function.

Nested functions:
A local function can in turn have one or even more definitions of local functions. These functions are only visible within the function in which they are defined.

Recursive calls:
A function can call itself recursively.

Primary and secondary sections within functions:
The function body can contain its own sections of it. These are local to this function, that means that these sections are only visible within the function.

calltype is the call type of the parameter [val | ref]. val=Call by Value, ref=Call by Reference. Default: val

parameter is the free selected name of the call parameter which is available as a local variable within the function under the aforementioned name.

ptype is the type of data of the parameter wether string or stringlist.

ftype is the type of data of the function wether string ,stringlist or void. void declares that no result is returned.

<function body>: is the body of the function which opsi-script syntax must suffice.
In this part there is the automaticly decared local variable $result$ which should take the result of the function an so have the data type of the function.

9.19. Import von Library Funktionen [W/L]

importLib <string expr> ; import library // since 4.12.0.0
<string expr> : <file name>[.<file extension>][::<function name>]
If no .<file extension> is given .opsiscript is used as default.
If no ::<function name> is given, all function from the given file will be imported.

<file name> is:

A complete path to an existing file. [W/L]

A existing file in %ScriptPath% [W/L]

A file in %opsiScriptHelperPath%\lib [W]
Is equivalent to: %ProgramFiles32Dir%\opsi.org\opsiScriptHelper\lib

A existing file in %ScriptPath%/../lib [W/L]

A existing file in %WinstDir%\lib [W] or /usr/share/opsi-script/lib [L]

The tests for the location of the <file name> are done in the order above. opsi-script uses the first file it finds that has a matching name.

Chapter 10. Secondary Sections

The secondary sections can be called from any primary section but have a different syntax. The syntax is derived from the functional requirements and library conditions and conventions for the specific purposes. Therefore from a secondary section, no further section can be called.

Secondary sections are specific each for a certain functional area. This refers to the object of the functionality, e.g. file system in general, the Windows registry, or XML files. But it refers even more to the apparatus that is internally applied. This may be demonstrated by the the variants of the batch sections (which call external programs or scripts).

The functional context is mirrored in the specific syntax of the particular section type.

10.1. Files Sections

A Files section mainly offers functions which correspond to copy commands of the underlying operating system. The surplus value when using the opsi-winst/opsi-script commands is the detailed logging and checking of all operations when necessary. If wanted overwriting of files can be forbidden if newer versions of a file (e.g. a newer dll-file) are already installed on the system.

10.1.1. Example

These commands cause that all files of the directory
p:\install\instnsc\netscape are copied to the directory C:\netscape, and then all files from p:\install\instnsc\windows to the windows system directory (its value is automatically inserted into the constant name %SYSTEMROOT%).
Option -s means that all subdirectories are copied as well, -V activates the version control for library files.

10.1.2. Modifier

In most cases a Files section will be called without parameters.

There are only some special uses of Files sections where the target of copy actions is set or changed in a certain specified way. We have got the two optional parameters

/AllNTUserProfiles resp.

/AllNTUserSendTo

Both variants mean:
The called Files section is executed once for each local Windows NT user.
Every copy command in the section is associated with an user specific target directory.

In case other we need to build other user specific path names we can use the automatically set variable %UserProfileDir% or since opsi-winst/opsi-script version 4.11.2 %CurrentProfileDir%.
With option /AllNTUserProfiles the user specific target directory for copy actions is the user profile directory (that is usually denoted by the user name and is by default situated as a subdirectory of the userappdata directory. In case of option /AllNTUserSendTo the target directory is the path of the user specific SendTo folder (for links of the windows explorer context menu).

The exact rule for determining the target path for a copy command has three parts:

If only the source of a copy action is specified the files are copied directly into the user target directory. We have syntaxcopy <source file(s)>
It be equivalent ascopy <source file(s)> "%UserProfileDir%"
or since 4.11.2copy <source file(s)> "%CurrentProfileDir%"

If some targetdir is specified and targetdir is a relative path description (starting neither with a drive name nor a backslash) then targetdir is regard as the name of a subdirectory of the user specific directory. I.e.copy <source file(s)> <targetdir>
is interpreted like:copy <source file(s)> "%UserProfileDir%\targetdir"
or since 4.11.2copy <source file(s)> "%CurrentProfileDir%\targetdir"

The use of %CurrentProfileDir% has the advantage that you may the same Files section with /AllNTUserProfiles if it is not running as userLoginScript (in Machine script mode) and without /AllNTUserProfiles if it is running as userLoginScript (in Login script mode).

If targetdir is an absolute path it is used as the static target path of the copy action.

SourcePath and CheckTargetPath set origin and destination of the forthcoming copy actions (as if we would open two explorer windows for copy actions between them). If the target path does not exist it will be created.

The syntax definitions are:

Copy [-svdunxwnrh] <source(mask)> <target path>

The source files can be denoted explicitly, using the wild card sign (”* ”) or by a directory name.

Caution

The <target path> is always understood as a directory name. Renaming by copying is not possible. If the target path does not exist it will be created (if needed a hierarchy of directories).

The optional options of the Copy command mean (the ordering is insignificant):

s → We recursive into subdirectories. [W/L]

e → Empty Subdirectories.
If there are empty subdirectories in the source path they will be created in the target directory as well.

V → Version checking [W]
A newer version of a windows library file is not overwritten by an older one (according primarily to the internal version counting of the file). If there are any doubts regarding the priority of the files a warning is added to the log file.

v → (do not use)
With Version checking: [W]
Deprecated: Don’t use it on Systems higher than win2k. Because it checks not only against the target directory but also against %System%.
use -V instead.

d → With date check: [W]
A newer .exe file is not overwritten by an older one.

u → We are only updating files: [W]
A file is not copied if there is a newer or equally old file of the same name.

x → x-tract [W]
If a file is a zip archive it will be unpacked (Xtracted) on copying.
Caution: Zip archives are not characterized by its name but by an internal definition. E.g. a java jar file is a zip file. If it is unpacked the application call will not work.

w → weak [W]
We respect any write protection of a file such proceeding "weakly" (in opposite to the default behaviour which is to try to use administrator privileges and overwrite a write protected file).

n → no over write [W]
Existing files are not overwritten.

c → continue [W]
If a system file is in use, then it can be overwritten only after a reboot. The opsi-winst/opsi-script default behaviour is therefore that a file in use will be marked for overwriting after the next reboot, AND the opsi-winst/opsi-script reboot flag is set. Setting the copy option -c turns the automatic reboot off. Instead normal processing continues, the copying will be completed only when a reboot is otherwise triggered.

r → read-only Attribute [W]
If a copied file has a read-only attribute it is set again (in opposite to the default behaviour which is to eliminate read-only attributs).

h → follow symlinks [L] //since 4.11.6.14
At Linux symlinks to files or directories will be resolved before copy.
So not the symlink but its target will be copied.

Delete [-sfd[n]] <path>

or

Delete [-sfd[n]] <source(mask)>

deletes files and directories.

Possible options are (with arbitrary ordering)

s → subdirectories
We recurse into subdirectories. Everything that matches the path name or the source mask is deleted.

Caution

The commanddelete -s c:\opsi
Do not mean: remove the directory c:\opsi recursive, but it means: delete starting frm c:\ all occurences of opsi. This may lead to a complete hard disk scan.
If you want to delete the directory c:\opsi recursive use the command:delete -s c:\opsi\
by using a trailing backslash you define that opsi is a directory.It is safer to use the command del instead.

f → force
forces to delete read only files

c → continue
If a system file is in use, then it can be deleted only after a reboot. The opsi-winst/opsi-script default behaviour is therefore that a file in use will be marked for delete after the next reboot, AND the opsi-winst/opsi-script reboot flag is set. Setting the copy option -c turns the automatic reboot off. Instead normal processing continues, the deleting will be completed only when a reboot is otherwise triggered.

d [n] → date
Only files of age n days or older are deleted. n defaults to 1.

del [Options] <path[/mask]] //since 4.11.2.1
Works like delete but ondel -s -f c:\not-exists
if c:\not-exists not exists it do not search complete c:\ for not-exits

hardlink <existing file> <new file> // since 4.11.5 [W/L]
A existing <new file> will be over written.hardlink works only on filesystems that support hard links like NTFS and standard Linux filesystems.

symlink <existing file> <new file> // since 4.11.5 [W/L]
A existing <new file> will be over written.
At Windows is symlink only available since NT6 and up !

rename <old filename> <new filename> // since 4.11.5 [W/L]move <old filename> <new filename> // since 4.11.5 [W/L]
There is no difference between rename and move, that are just two names for the same function
A existing <new file> will be over written.
At the moment it is not possible to move or rename directories.

Windows: <new filename> may be located in a differen directory or volume / disk. In the second case (different volume / disk) the file will be copied and than the original file will be deleted.
If it is not possible to create the target file becaus the file is in use, then it can be overwritten only after a reboot. The opsi-winst/opsi-script default behaviour is therefore that a file in use will be marked for overwriting after the next reboot, AND the opsi-winst/opsi-script reboot flag is set. Setting the copy option -c turns the automatic reboot off. Instead normal processing continues, the copying will be completed only when a reboot is otherwise triggered.
Creating Junctions at Windows is not supported right now.

Linux: <new filename> may be located in a different directory but not in a different filesystem. The Option -c will be ignored at Linux.

10.2. Patches-Sections [W/L]

A Patches section modifies a property file in ini file format. I. e. a file that consists of sections which are a sequence of entries constructed as settings <variable> = <value>. where sections are characterized by headings which are bracketed names like [sectionname].

For more examples, please check the opsi standard product opsi-script-test and in this product the part $Flag_winst_patches$ = "on"

Call Parameter

The name of the file to be patched is passed as a parameter.

There are optional modifiers:

/AllNTUserProfiles
If a patch section is called with this modifier, then all directories under %UserProfileDir% will be patched, which means that this patch is performed for all user profiles.
When a Patches is called within a [ProfileActions] section, then the modifier /AllNTUserProfiles is implicit. In logscript mode, %UserProfileDir% will be interpreted as %CurrentProfileDir%.
(Since Version 4.11.3.2)

10.2.2. Commands

For a Patches section, we have commands:

add

set

addnew

change

del

delsec

replace

Each command refers to some section of the file which is to be patched. The name of this section is specified in brackets [] (which do here not mean "syntactically optional"!!).

In detail:

add [<section name>] <variable1> = <value1>
This command adds an entry of kind <variable1> = <value1> to section <section name> if there is yet no entry for <variable1> in this section. Otherwise nothing is written. If the section does not exist it will be created.

set [<section name>]<variable1> = <value1>
If there is no entry for <variable1> in section <section name> the setting <variable1> = <value1> is added. Otherwise, the first entry <variable1> = <valueX> is changed to <variable1> = <value1>.

addnew [<section name>]<variable1> = <value1>
No matter if there is an entry for <variable1> in section <section name> the setting <variable1> = <value1> is added.

change [<section name>]<variable1> = <value1>
Only if there is any entry for <variable1> in
section <section name> it is changed to <variable1> = <value1>.

replace <variable1>=<value1> <variable2>=<value2>
means that <variable1> = <value1> will be replaced by <variable2> = <value2> in all sections of the ini file. There must be no spaces in the value or around the equal signs.

10.3. PatchHosts Sections [W/L]

By virtue of a PatchHosts section we are able to modify a hosts file which is to understand as any file with lines having formatIPadress hostName aliases # comment

Aliases and comment (and the comment separator #) are optional. A line may also be a comment line starting with # .

The file which is to be modified can be given as parameter of a PatchHosts call. If there is no parameter a file named HOSTS is searched in the directories c:\nfs, c:\windows and %systemroot%\system32\drivers\etc. If no such file is found the PatchHosts call terminates with an error.

For more examples, please check the opsi standard product opsi-script-test and in this product the part $Flag_winst_patch_hosts$ = "on".

In detail:

setaddr <hostname> <ipaddresse>
sets the IP address for host <hostname> to <IPaddress>. If there is no entry for host name as yet it will be created.

setname <ipaddresse> <hostname>
sets the host name for the given IP address. If there is no entry for the IP address as yet it will be created.

setalias <hostname> <alias>
adds an alias for the host named <hostname>.

setalias <IPadresse> <alias>
adds an alias name for the host with IP address <IPadress>.

delalias <hostname> <alias>
removes the alias name <alias> for the host named <hostname> .

delalias <IPadresse> <alias>
removes the alias name <alias> for the host with IP address <IPadress>.

delhost <hostname>
removes the complete entry for the host with name <hostname>.

delhost <IPadresse>
removes the complete entry for the host with IP address <IPadress>.

setComment <ident> <comment>
writes <comment> after the comment sign for the host with host name, IP address or alias name <ident>.

10.4. IdapiConfig Sections

A IdapiConfig section were designed to write parameters in idapi*.cfg files which are used by the Borland Database Engine.

This section type is not supported any more.

10.5. PatchTextFile Sections [W/L]

A PatchTextFile section offers a variety of options to patch arbitrary configuration files which are given as common text files (i.e. they can be treated line by line).

An essential tool for working on text files is the check if a specific line is contained in a given file. For this purpose we have got the Boolean functions Line_ExistsIn and LineBeginning_ExistsIn (cf. Section 9.14.2, “Boolean Expressions”).

10.5.1. Parameter

The text file which is to be treated is given as parameter.

There are optional modifiers:

/AllNTUserProfiles
If a PatchTextFile section is called with this modifier and the path of the file to be patched contains the constant %UserProfileDir%, the patch section will be executed for all the profiles.
For a PatchTextFile section which is called from a [ProfileActions] section in the Machine mode the modifier /AllNTUserProfiles is implied. In the Loginscript Mode the %UserProfileDir% is interpreted as %CurrentProfileDir%.
(since version 4.11.3.5)

10.5.2. Commands

We have got two commands especially for patching Mozilla preferences files plus the two deprecated and more restricted older versions of these commands:

Set_Mozilla_Pref ("<preference type>", "<preference key>", "<preference value>")
sets for <preference type> the value associated with "<preference variable>" to "<preference value>".
In current Mozilla preference files there are expressions likeuser_pref("<key>", "<value>")
pref("<key>", "<value>")
lock_pref("<key>", "<value>")
defaultPref("<key>", "<value>")
lock_pref("<key>", "<value>")
clearPref("<key>", "<value>")
Each of them, in fact, any (javascript) function call of the formfunctionname (String1, String2)
can be patched with this command by setting the appropriate string for <preference type> (that is, resp. for functionname),
If an entry starting with "functionname (String1" exists in the treated file, it will be patched (and left at its place). Otherwise a new line will be appended.
Unusually in opsi-winst/opsi-script, all strings are case sensitive.

Set_Netscape_User_Pref ("<preference variable>", "<value>")
sets the line of the given user preference file for the variable <preference variable> to value <value>. The ASCII ordering of the file will be rebuilt.
(Deprecated!)

AddStringListElement_To_Mozilla_Pref ("<preference type>", "<preference variable>", "<add value>")
appends an element to a list entry in the given preference file. It is checked if the value that should be added is already contained in the list (then it will not be added).

The other commands of PatchTextFile sections are not file type specific. All operations are based on the concept that a line pointer exists which can be moved from top of the file i.e. above the top line down to the bottom (line).

FindLine_StartingWith <search string>
Finds a line that starts with <search string>.

FindLine_Containing <search string>
Finds a line that contains <search string>.

Each command starts searching at the current position of the line pointer. If they find a matching line the line pointer is moved to it. Otherwise the line pointer keeps its position.
The search is not case sensitive.

<search string> - as all other String references in the following commands - are String surrounded by single or double citation marks.

GoToTop
move the line pointer to the top line.

(when we count lines it has to be noted that this commands move the line pointer above the top line).
We step any - positive or negative - number of lines through the file by

setValueByKey <keystr> <valuestr> //since 4.11.4.4
looks for a key/value pair with the key <keystr> and set here as value <valuestr>. Is <keystr> not found, the entry will be created at the cursor position.

10.5.3. Examples

For more examples, please check the opsi standard product opsi-script-test and in this product the part $Flag_winst_patch_text_file$ = "on"

10.6. LinkFolder Sections [W/L]

In a LinkFolder section start menus entries as well as desktop links are managed.

10.6.1. LinkFolder Sections in Windows

E.g. the following section creates a folder named "acrobat“ in the common start menu (shared by all users):

These folders are virtual, for it depends on the operating system (and version), what the resulting physical directory name is.

In the context of standard maschine installations, only the virtual system folders starting with common_ are relevant.

The system folders desktop, sendto, startmenu, startup, programs, desktopdirectory can only be used in the context of a logged on user respectively in a userLoginScript in the context of the opsi extension user Profile Management.

The folders are virtual since the operating system (resp. registry entries) determine the real places of them in the file system.
Second, we have to open a subfolder of the selected virtual folder:set_subfolder <folder path>
The subfolder name is to be interpreted as a path name with the selected virtual system folder as root. If some link shall be directly placed into the system folder we have to writeset_subfolder ""

In the third step, we can start setting links. The command is a multi line expression starting withset_link
and finished by
end_link.

Between these lines the link parameters are defined in the following format:

set_linkname: [link name]target: <complete program path>parameters: [command line parameters of the program]working_dir: [working directory]icon_file: [icon file path]icon_index: [position of the icon in the icon file]shortcut: [keyboard shortcut for calling the target]end_link

The target name is the only essential entry. The other entries have default values:

name defaults to the program name.

`parameters`defaults to a empty string.

icon_file defaults to the target.

icon_index defaults to 0.

shortcut defaults to empty. // since 4.11.6.7shortcut may be a combination of [shift,alt,ctrl] (not case sensitiv) divided by " " (Space) , "-" (minus char),"+" (plus char) and a Key or a Virtual Key Code.
The Key is a letter (A - Z) or a numeral (0 - 9). All other Keys must be given by there Virtual Key Code identifier. To get these identifier (as well as the allowed combinations) just use the following helper program:http://download.uib.de/opsi4.0/helper/showkeys.exe
Keep in mind that a shortcut refernces the keys and not there contry specific layout. The Key VK_OEM_3 is on an english keyboard the char ; and on a german the letter Ö.
Examples for allowed shurtcuts:

O (The Key O)

VK_O (The Key O)

Ctrl-O (The combination Ctrl O)

Ctrl-Alt-Shift-O (The combination Ctrl Alt Shift O)

Ctrl+Alt+Shift+O (The combination Ctrl Alt Shift O)

Ctrl Alt Shift O (The combination Ctrl Alt Shift O)

Ctrl-Alt-Shift-VK_O (The combination Ctrl Alt Shift O)

Ctrl-Alt-Shift-VK_F12 (The combination Ctrl Alt Shift F12)

Caution

If the referenced target does not lie on an mounted share at the moment of link creation windows shortens its name to the 8.3 format.
Workaround:
Create a correct link when the share is connected.
Copy the ready link file to a location which exists at script runtime.
Let this file be the target.

delete_element <Linkname>
remove a link from the open folder.

delete_subfolder <Folderpath>
folder is removed from the base virtual folder

Set $list2$ = createStringList ('common_startmenu', 'common_programs', 'common_startup', 'common_desktopdirectory')
retrieving strings from createStringList [switch to loglevel 7 for debugging]
(string 0)common_startmenu
(string 1)common_programs
(string 2)common_startup
(string 3)common_desktopdirectory
retrieving strings from $list2$ [switch to loglevel 7 for debugging]
(string 0)common_startmenu
(string 1)common_programs
(string 2)common_startup
(string 3)common_desktopdirectory
~~~~~~ Looping through: 'common_startmenu', 'common_programs', 'common_startup', 'common_desktopdirectory'
Execution of LinkFolder_Dummy
Base folder is the COMMON STARTMENU folder
Created "Dummy" in the COMMON STARTMENU folder
ShellLink "Dummy" created
Execution of LinkFolder_Dummy
Base folder is the COMMON PROGRAMS folder
Created "Dummy" in the COMMON PROGRAMS folder
ShellLink "Dummy" created
Execution of LinkFolder_Dummy
Base folder is the COMMON STARTUP folder
Created "Dummy" in the COMMON STARTUP folder
ShellLink "Dummy" created
Execution of LinkFolder_Dummy
Base folder is the COMMON DESKTOPDIRECTORY folder
Created "Dummy" in the COMMON DESKTOPDIRECTORY folder
ShellLink "Dummy" created
~~~~~~ End Loop

For more examples, please check the opsi standard product opsi-script-test and in this product the part $Flag_winst_link_folder$ = "on".

10.6.3. LinkFolder-Sections in Linux

LinkFolder sections are supported also on Linux since version 4.11.5.2.

The Link Option icon_index is ignored.
As additional Link Option we have: link_categories.
Here you may use the following values seperated and terminated by a semicolon:AudioVideo, Audio, Video, Development, Education, Game, Graphics, Network, Office, Settings, System, Utility
The LinkFolder Sektion will work at Linux with different Desktop systems

10.7. XMLPatch Sections [W]

Today, the most popular way to keep configuration data or data at all is a file in XML document format. Its syntax follows the conventions as defined in the XML (or "Extended Markup Language") specification (http://www.w3.org/TR/xml/).

With the actions defined for this section type opsi-winst/opsi-script can

select (and optionally create) sets of elements of a XML document according to a path description

patch all elements of a selected element set

return the names and/or attributes of the selected elements to the calling section

10.7.1. Parameter

When calling an XMLPatch section the document path name is given as parameter, e.g.XMLPatch_mozilla_mimetypes $mozillaprofilepath$ + "\mimetypes.rdf"

10.7.2. Structure of a XML Document

A XML document logically describes a "tree" which starting from a "root" - therefore named document root– grows into branches. Every branch is labelled a node. The sub nodes of some node are called children or child nodes of their parent node.

In XML, the tree is constructed from elements. The beginning of any element description is marked by a tag (similarly as in HTML) i.e. a specific piece of text which is set into a pair of angle brackets ("<“ ">“, The end of the element description is defined by the the same tag text but now bracket by "</“ and „>“. If an element has no subordinated elements then there is no space needed between start tag and end tag. In this case the two tags can be combined to one with end bracket "/>“.

This sketch shows a simple "V"-tree - just one branching at the root level, rotated so that the root is top:

If there are no subordinated elements an element can have subordinated text. Then it is said that the element has a subordinated text node. Example

<node_level_1_no_2>hello world
</node_level_1_no_2>

A line break placed in the text node is now interpreted as part of the text where otherwise it is only a means of displaying XML structure. To avoid a line break belonging to "hello world" we have to write

<node_level_1_no_2>hello world</node_level_1_no_2>

Every element (no matter if it has subordinated elements or subordinated text) is constituted as a main node with specific tags. It can be further specified by attributes, so called attribute nodes. For example, there may be attributes "colour" or "angle" that distinguish different nodes of level 1.

<node_level_1_no_1 colour="green" angle="65"
</node_level_1_no_1>

For selecting a set of elements any kind of information can be used:

the element level,

the element names that are traversed when descending the tree (the "XML path"),

names and values of the used attributes,

the ordering of attributes,

the ordering of elements,

other relationships of elements,

the textual content of elements (resp. their subordinated text nodes).

In opsi-winst/opsi-script, selection based on criteria (1) to (3) and (7) is implemented

10.7.3. Options for Selection a Set of Elements

Before any operation on the contents of a XML file the precise set of elements has to be determined on which it will be operated. The set is constructed step by step by defining the allowed paths through the XML tree. The finally remaining end points of the paths define the selected set.

The basic opsi-winst/opsi-script command is

OpenNodeSet

There two formats for defining the allowed paths a short and a long format .

With short syntax, parametrizing precedes the OpenNodeSet command and holds for all levels of the XML tree. With the explicit syntax the parameters may be set directly after the OpenNodeSet command or be newly set for each level. In particular the option „create when node not existing“ may be set for some levels but not for all.

10.7.4. Patch Actions

There exists a bundle of commands which operate on a selected element set

for setting and removing attributes

for removing elements

for text setting..

In detail:

SetAttribute "attribute name" value="attribute value"
sets the specified attribute for each element in the opened set to the specified value. In the attribute does not exist it will be created.
Example:
SetAttribute "name" value="OpenOffice Writer"

On the contrary, the command

AddAttribute "attribute name" value="attribute value"
sets the specified attribute only to the specified value if it does not exists beforehand. An existing attribute keeps its value. E.g. the commandAddAttribute "name" value="OpenOffice Writer"
would not overwrite the value if there was named another program before.

By
* DeleteAttribute "attribute name"
we remove the specified attribute from each element of the selected element set.

The command
* DeleteElement "element name"
removes all elements with main node name (tag name) element name from the opened element set.

The variantAddText "rtf"
sets the text only if there was no text node given.

10.7.5. Returning Lists to the Caller

A XMLPatch section may return the retrieved informations to the calling primary section. The result always is a String list, and to get it, the call must done via the String list function getReturnListFromSection. E.g. we may have the following String list setting in an Actions section where we use a XMLPatch_mime section

Inside the XMLPatch section we have return commands that determine the content of returned String list:

return elements+
fills the selected elements completely (element name and attributes) into the return list.

return attributes
produces a list of the attributes.

return elementnames
produces a list of the element names.

return attributenames
gives a list only of the attribute names.

return text
list all textual content of the selected elements.

return counting
gives a report with numerical informations: line 0 contains the number of selected elements, line 1 the number of attributes.

10.7.6. Examples

For further examples see the product opsi-script-test
expecially the sector with $Flag_winst_xml$ = "on"

10.8. ProgmanGroups Sections

This section type is deprecated.

10.9. WinBatch-Sections [W/L]

In a WinBatch section any windows executable can be started.
E.g, we may start some existing setup program by the following line in a WinBatch section

[winbatch_install]
"%scriptpath%\setup.exe"

Winbatch section are desingned to start programs (*.exe) directly.
To call data files that are connected to programs is deprecated but still supported. If you do this you will get a depricated warning. Example:
ok: notepad.exe test.txt
depricated (not ok): test.txt

10.9.1. Call Parameter (Modifier)

There a several parameters of the WinBatch call which determine if (or how long) opsi-winst/opsi-script shall be wait for the started programs returning.

/WaitOnClose
Is the defaultopsi-winst/opsi-script waits for every initiated process to come back.

/LetThemGo
This is the contrary to /WaitOnClose. It is used if opsi-winst/opsi-script shall proceed while the started processes run in their own threads.

/WaitSeconds [number of seconds]
If a call includes the parameter /WaitSeconds [number of seconds], then opsi-winst/opsi-script is waiting for [number of seconds] before proceeding. In the default configuration, we also wait for any programs that are currently running to finish. If we combine the parameter /WaitSeconds with the option /LetThemGo, then opsi-winst/opsi-script continues processing after the waiting time is finished.

/WaitForProcessEnding <program name>
Waits for the process called <program name> to end.
Should be combined with /TimeOutSeconds.

Explanation:
When starting an external process from a winbatch call, the opsi-winst/opsi-script waits for the current process to finish before executing the next command in the script.

/32Bit //since 4.11.3.5 [W]
This is the default. The paths within the section are assumed to be 32 bit pathes.
Example: c:\windows\system32\regedit.exe calls (even when running on a 64 bit system) the 32 bit regedit.exe.

/64Bit //since 4.11.3.5 [W]
The paths within the section are assumed to be 64 bit paths.
Example: c:\windows\system32\regedit.exe executes (running on a 64 bit system) the 64 bit regedit.exe.

/SysNative //since 4.11.3.5 [W]
The paths within the section are assigned according to the OS architecture interpretiert.
Example: c:\windows\system32\regedit.exe running on a 64bit system calls the 64 bit regedit.exe and running on a 32 bit system the 32 bit regedit.exe.

/RunAsLoggedonUser //since 4.11.3.5 [W]
This is available only in the context of userLoginScripts. The program is executed as the user, who has just logged on.
This modifier has the following limitation:

insufficient tested on NT6 and possibly of limited effect.

Figure 10.1. Sequential processing of a script that waits for the end of a program

There are some external programs which start another process and then end without waiting for their child process to end. From the point of view of opsi-winst/opsi-script, the process is ended and the next command could be started.

Figure 10.2. End of process while child process is still running

If you run an uninstall program and a setup program in sequence and the uninstall program works with such a child process, you can have conflicting processes running because the uninstallation and installation processes are running at the same time.

Figure 10.3. Overlapping of a child process and a parent process

Using the modifier /WaitForProcessEnding helps to avoid such a situation.

/TimeOutSeconds <seconds>
A timeout setting. After waiting <seconds>, opsi-winst/opsi-script will end the process.
Since version 4.11.3, /TimeOutSeconds may be used without a waiting condition (e.g. /WaitForProcessEnding) but not in combination with /WaitSeconds.
Since version 4.11.4.6 the time progress from start until timeout is displayed by the progressbar.
Example:

/RunElevated [W]
Starts a process that has a security token with elevated privileges. This modifier has the following restrictions:

For NT5 it does not change anything.

A process started with this modifier has no network access. So you should copy a program to a temporary local directory, but do not start it from a network share.

You may see problems while using the graphical interface. Therefore true silent installations are the better choice in this case.

Functions only in the context of opsi-winst/opsi-script.

getLastExitCode
Returns a string that contains the value of the exitcode of the the process that was last called by a WinBatch / DosBatch / ExecWith section.
When using a DosBatch or ExecWith section, you will normally get the exitcode of the interpreter that was called. To get the exitcode of your script you have to define it explicitly.

/RunAsLoggedOnUser // since 4.11.3.5 [W] ; works only inside userLoginScripts

/32Bit or /64Bit or /SysNative //since 4.11.3.5 [W]
These modifiers control if the path to a called program is interpreted as 32 or 64 Bit Path. So if want for example call a %system%\cmd.exe you call a 32 bit program by default. If you use the /64bit modifier you will get with the same call the 64 bit version.

The first option means that opsi-winst/opsi-script waits until any process lets pop up a window with title window title. With the second option opsi-winst/opsi-script is waiting as long as a certain window (1) appeared on the desktop and (2) disappeared again.
CAUTION: These options only know windows of 32-bit programms

10.9.2. Examples

For further examples see the product opsi-script-test
expecially the sector with $Flag_winst_winbatch$ = "on"

10.10. DOSBatch/DosInAnIcon (ShellBatch/ShellInAnIcon) Sections [W/L]

Via DOSBatch (also called ShellBatch) sections a opsi-winst/opsi-script script uses Windows shell scripts for tasks which cannot be fulfilled by internal commands or for which already a batch script solution exists.

opsi-winst/opsi-script waits until the DOS-batch ends, before it is proceeding with the next script-section.

A DOSBatch section is simply processed by writing the lines of the sections into the file _winst<random>.cmd in c:\opsi.org\tmp\ and then calling this file in the context of a cmd.exe shell. This explains that a DosBatch section may contain all Windows shell commands can be used.

Compared with calling a cmd-file in a WinBatch section, the DOSBatch section
presents certain advantages:

opsi-winst/opsi-script variables or constants in the section can be easily used because they will be substituted before execution.

The output of a DosInAnIcon/ShellInAnIcon call at Windows is written to the log file.

The output of a DosInAnIcon/ShellInAnIcon or DosBatch/ShellBatch call at Linux is written to the log file.

The output of a DosInAnIcon/ShellInAnIcon call is written to an output window if the section is called with the parameter /showoutput.

The output of the shell commands can be captured by using the String list function.

The section type DOSInAnIcon or ShellInAnIcon is identical to DOSBatch/ShellBatch regarding syntax and execution method but has a different appearance:
For DOSInAnIcon/ShellInAnIcon, a shell process is created with view set to minimized. That has the consequence that it is executed "in an icon". No command window appears, user interaction is suppressed. The output of the call is written to the log file.

Caution

Don’t use commands that wait for user interaction.

10.10.1. Parameter

There are two kinds of parameters which may be passed to the section call:

Parameters which are directly passed to the called batch file.

Parameter which modify the way opsi-winst/opsi-script will handle the section.

The calling syntax is:

Sektionsname [batch parameter] [winst [modifier]]

Possible winst modifier are (since 4.11.1):

/32bit

/64bit

/Sysnative

/showoutput // since 4.11.4.6

These winst modifier have to be separated by the key word winst from the other parameters.

Other parameters of a DosBatch section are directly passed as quasi command line parameters to the Windows shell script.
For example, we may call DosBatch_1 in Actions section to get a "Hello World" from the DOS echo command:

If the return list shall be evaluated programmatically it is advised to use the @ prefix of commands. Such we suppress the repetition of the command line in the output which may different formats dependent on system configurations.

10.10.3. Examples

For further examples see the product opsi-script-test
and there look at $Flag_winst_dos$ = "on"

10.11. Registry-Sections [W]

By a Registry section call we can create, patch and delete entries in the Windows registry. As usual, opsi-winst/opsi-script logs every operation in detail as long as logging is not turned off.

10.11.1. Examples

Let us set some registry variables by a call to the section Registry_TestPatch where the section is given by

For further examples see the product opsi-script-test
and there look at $Flag_subregistry$ = "on"

10.11.2. Call Parameters

The standard call of a Registry section has no parameters. This is sufficient as long as the operations aim at the standard registry of a Windows system and all entries can be defined using a globally defined registry path.

/AllNTUserDatsopsi-winst/opsi-script also offers that the patch commands of a Registry section are automatically executed "for all users" which are locally defined. I.e. the patches are made for all user branches of the local registry. This interpretation of the section is evoked by the parameter /AllNTUserDats

Further parameters control which syntactical variant of the Registry section shall be valid:

/regedit
The parameter /regedit declares that the syntax corresponds the export file syntax of the Windows Registry Editor regedit. Such, the lines of a regedit export file may directly be used as a Registry resp. the file itself can serve as an external section (see Section 10.11.5, “Registry Sections in Regedit Format”).

10.11.3. Commands

The default syntax of a Registry section is oriented at the command syntax of other patch operations in opsi-winst/opsi-script.

There exist the following commands:

OpenKey

Set

Add

Supp

GetMultiSZFromFile

SaveValueToFile

DeleteVar

DeleteKey

ReconstructFrom

Flushkey

In detail:

OpenKey <registry key>
opens the specified key for reading and (if the user has the necessary privileges) for writing. If the key does not exist it will be created.

The registry key is denoted by a registry path name. Under regular circumstances it starts with one of the "high keys" which build the top level of the registry tree data structure (above the "root" ). These are:
HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CURRENT_CONFIG which may optionally be written as HKCR, HKCU, HKLM, HKU.

In opsi-winst/opsi-script syntax of the registry path name, the elements of a path are separated by single backslashs.

All other commands operate on an opened registry key.

Set <varname> = <value>
sets the registry variable <varname> to value <value>.
<varname> as well as <value> are strings and have to be enclosed in citations marks. A non-existing variable will be created. As default data typ normally REG_SZ is used. But if <value> contains a percent char (%) REG_EXPAND_SZ will be used instead.

The empty variable "" denotes the standard entry of a registry key.

If some registry variable shall be created or set where the data type should be explicitly given, we have to use the extended variant of the Set command:

Set <varname> = <registry type>:<value>
sets the registry variable <varname> to value <value> of type <registry type>. The following registry types are supported:

Add <varname> = <registry type> <value>
are analogous to the Set commands with the difference that entries are only added but values of existing variables not changed.

Supp <varname> <list separator> <supplement>
This command interprets the string value of variable <varname>, a list of values separated by <list separator> and adds the string <supplement> to this list (if it not already contained). If <supplement> contains the <list separator> it is split into single strings, and the procedure is applied to each single string.
A typical use is adding entries to a path variable (which is defined in the registry).Supp keeps the original string variant (REG_EXPAND_SZ or REG_SZ).

Example:
The environment Path is determined by the value for the variable Path as defined inside the registry key

DeleteVar <Varname>
removes the entry with variable <varname> from the opened key.

DeleteKey <Registrykey>
deletes the registry key recursively including all subkeys and contained variables. The registry key is defined as for OpenKey.

Example:

[Registry_Keydel]
deletekey [HKCU\Environment\subkey1]

ReconstructFrom <filename>
(deprecated)

FlushKey
ensures that all entries of a key are saved on hard drive, not only in memory (is automatically done when closing a key, therefore in particular when a registry section is left).

10.11.4. Registry Sections to Patch All NTUser.dat

A Registry section called with parameter /AllNTUserdats is executed for every local user.

To this end, for all local users (as permanent storage for the registry branch HKEY_Users) the files NTUser.dat are searched one by one and temporarily loaded into a subkey of some registry branch. The commands of the registry section are executed for this subkey, then the subkey is unloaded. As result, the stored NTUser.dat is changed.

The mechanism does not work for a logged in user. For, his NTUser.dat is already in use, and the request to load it produces an error. To do the changes for him as well, the commands of the Registry additionally are executed on the HKEY_Users branch for the logged in user.

There is a NTUser.dat for Default User which serves as template for newly created users in the future. Therefore the patches are prepared for them as well.

The Registry section syntax remains unchanged. But the key pathes are interpreted relatively. This means leave away the main key

In the following example the registry entry for variable FileTransferEnabled is de facto set for all HKEY_Users\XX\Software… successive for all XX (all users) on the machine:

The same registry section may be used with /AllNtuserdats and in a userLoginScript

10.11.5. Registry Sections in Regedit Format

If a Registry section is called with parameter /regedit the section is not expected in opsi-winst/opsi-script standard format but in the format as produced by the Windows regedit tool.
The export files generated by regedit have - not regarding the head line - ini file format. Example:

The sections denote registry keys to be opened. Each line describes some variable setting like the set command in a opsi-winst/opsi-script registry section.

But, we cannot really have an internal opsi-winst/opsi-script section that is constructed from another sections. Therefore Registry section with parameter /regedit can only be given as external section or by the function call loadTextFile, e.g.

registry "%scriptpath%/opsiorgkey.reg" /regedit

With Windows XP the registry editor regedit does not produce Regedit4-Format but a new format that is indicated by the head line"Windows Registry Editor Version 5.00"

In this format, Windows offers some additional value types. But more important, the export file is now generated in Unicode. opsi-winst/opsi-script sections processing is based on Delphi libraries which use 8 bit Strings. To work with a regedit 5 export the coding therefore has to converted. This can be done manually, e.g. by a suitable editor. But we may also feed the original file to opsi-winst/opsi-script using the String list function loadUnicodeTextFile. E.g., if printerconnections.reg be a unicode based export, we can call regedit in the following form which does the necessary code conversion on the fly:

registry loadUnicodeTextFile("%scriptpath%/opsiorgkey.reg") /regedit

A registry patch using regedit format can as well be executed "for all NT users" similarly as the common opsi-winst/opsi-script registry section. That is, a path like
[HKEY_CURRENT_USER\Software\ORL] is to replaced by the relative [Software\ORL].

10.11.6. Registry Sections in AddReg Format

A Registry section can be called with parameter /addReg. Then its syntax follows the principles of the [AddReg] sections in inf files as used e.g. for driver installations.

10.12. OpsiServiceCall Sections [W/L]

This type of section allows to retrieve information – or set data – via the opsi service. There are three options for determining a connection to an opsi service:

Per default it is assumed that the script is executed in the standard opsi installation environment. I.e., we already have a connection to an opsi service and can use it.

We set the url of the service to which we want to connect as a section parameter and supply as well the required username and password as section parameters.

We demand an interactive login to the service (predefining only the service url and, optionally, the user name).

Retrieved data may be returned as a String list and then used for scripting purposes.

10.12.1. Call Parameters

Caution

There is a standard webservice connection. This is established at the start of the opsi-script via the opsi-client-agent on the existing connection to the current opsi-server.
If no call parameters are specified, the standard connection is applied. If it’s not specified, then the call fails.
There are a number of call parameters that create a new connection.
This new connection will be the default connection. That means, that subsequent calls without parameters use this connection until it is explicitly changed again, or the product script has been processed.
A new product starts the original webservice connection again.

The call parameters that change the standard connection:

/interactive

/serviceurl /username /password

/opsiclientd

Restore of the original connection:

With the opsiServiceCall section with a parameter call /preloginservice the standard connection will be restore to the previous value. Alternatively one can also make a
call to the statement without an actual existing section:opsiServiceCall /preloginservice

The parameter call:

The call parameters determine which opsi service will be addressed and set the connection parameters if needed.

Connection parameters can be defined via

/serviceurl <url to the opsi web service>

/username <web service user name>

/password <web service user password>

If these parameters are defined (or at least one of them), an attempt is made to connect to the mentioned service URL and, if successful, then this will be the default connection.

The additional option

/interactive

raises an interactive connect. The user will be asked for confirming the connection data and supplying the password. Of course, this option cannot be used in scripts which shall be executed fully automatically.

If no connection parameters are supplied opsi-winst/opsi-script assumes that an existing connection shall be reused.

If no connection parameters are given and the interactive option is not specified (neither at this call nor at a call earlier in the script) it is assumed that we are in a standard opsi boot process and, already having a connection to an opsi service, we try to address it.

/preloginservice
In the case that we had a connection to a secondary opsi service we may (re)set the connection to the standard opsi service via the option

/opsiclientd //since 4.11.2.1
calls the localhosts opsiclientd

/opsiclientd-once //since 4.11.6.11
Calls the webservice from the local opsiclientd and sets back after the call, the standard connection once again to the original value.

10.12.2. Section Format

An opsiServiceCall, which uses an existing connection to an opsi-service, is defined by its method name and a list of parameters.

Both are defined in the section body. It has format

"method":<method name>
"params":[
<params>
]

params is a (possibly empty) list of strings (comma-seperated). Use the parameters as required by the specified method.

E.g. we may have a section call where the required methodname and the (empty) list of parameters is set:

Object oriented Methods. Dealing with JSON objects from the web service requires a basic understanding of JSON, the opsi objects and the JSON-related methods in opsi-script.
See also:
Opsi-manual: Chapter: "Web service / API methods since opsi 4.0"
In this manual: ####

In the code shown below, you can get objects from the service.
In this example, all productOnClient objects that belong to the current computer will be retrieved (% opsiserviceUser% are in the service context of the FGDN of the client) and are localboot products, by which the action request is set to setup.

10.12.3. Examples

For further examples watch the product opsi-script-test an there especially $Flag_winst_opsiServiceCall$ = "on"

10.13. ExecPython Sections [W/L]

ExecPython sections are basically Shell-Sections (like DosInAnIcon) which call the – on the system installed – python script interpreter. It takes the section content as python script, and the section call parameter as parameters for the script.

Example:

The following example demonstrates a execPython call with a list of parameters for that are printed by the python commands.

The print command output will be caught and written to the log file. So we get in the log

output:
------------
-a
option a
-b
option b
there we are
hello

Observe that the loglevel must be set at least to info (that is 1) if these outputs shall really find their way to the log file.

10.13.1. Interweaving a Python Script with the opsi-winst Script

An execPython section is integrated with the surrounding opsi-winst/opsi-script script by four kinds of shared data:

A parameter list is transferred to the python script.

Everything that is printed by the python script is written into the opsi-winst/opsi-script log.

The opsi-winst/opsi-script script substitution mechanism for constants and variables when entering a section does its expected work for the execPython section.

The output of an execPython section can be caught into a stringlist and then used in the ongoing opsi-winst/opsi-script script.

An example for the first two ways of interweaving the python script with the opsi-winst/opsi-script script is already given above. We extend it to retrieve the values of some opsi-winst/opsi-script constants or variables.

The option /EscapeStrings is automatically used in an ExecPython section and means that backslashes in String variables and constants are duplicated before interpretation by the the called program.

10.14.1. Calling parameters (Modifier)

In general, we have the call syntax:

ExecWith_SECTION PROGRAM PROGRAMPARAS pass PASSPARAS winst WINSTOPTS

Each of the expressions PROGRAM, PROGRAMPARAS, PASSPARAS, WINSTOPTS may be an arbitrary String expression, or just a String constant (without citation marks).

The key words PASS and WINST may be missing if the respective parts do not exist.

The following opsi-winst/opsi-script-options are available:

/EscapeStrings

/LetThemGo

/32Bit
This is the default. The interpreter path is assumed to be a 32 bit path.
Example: c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe calls (also when running on a 64 bit system) the 32 bit powershell.exe.

/SysNative
The given interpreter path is assigned accoring to the OS architecture.
Example: c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe calls on a 64 bit system the 64 bit powershell.exe and running on a 32bit system the 32 bit powershell.exe.

Like with ExecPython sections, the output of an ExecWith section may be captured into a String list via the function getOutStreamFromSection.

The first one declares that the backslash in opsi-winst/opsi-script variables and constants is C-like escaped. The second one has the effect (as for winBatch calls) that the called program starts its work in new thread while opsi-winst/opsi-script is continuing to interpret its script.

Since Version 4.11.3.5, if the interpreter path contains powershell.exe, the temporary file is saved with the extension .ps1.

10.14.2. More Examples

The following call is meant to refer to a section which is an autoit3 script that waits for some upcoming window (therefore the option /letThemGo is used) in order to close it:

ExecWith_close "%SCRIPTPATH%\autoit3.exe" WINST /letThemGo

A simple

ExecWith_edit_me "notepad.exe" WINST /letThemGo

calls notepad and opens the section lines in it (but without any line that is starting with a semicolon since opsi-winst/opsi-script regards such lines as comments and eliminates them before handle).

For Powershell the script execution is disabled by default. So you have to enable it before you can use Execwith with powershell.
In order to to that you shold call powershell.exe set-executionpolicy RemoteSigned in a DosInAnIcon.
Example

For further examples watch the product opsi-script-test and there especially
$Flag_autoit3_test$ = "on"

10.15. LDAPsearch Sections [W]

A LDAPsearch section defines a search request to a LDAP directory, executes it and receives (and possibly caches) the response.

Before dwelling on the opsi-winst/opsi-script commands we do some explanations.

In subsection we give an example of the most probable usage of a LDAPsearch.
The following subsections describe the syntax

10.15.1. LDAP – Protocol, Service, Directory

LDAP, the "Lightweight Directory Access Protocol", is, as the name indicates, a defined way of communication to a directory. This directory is (or may be) hierarchically organized. That is, the directory is a hierarchical data base, or a tree of content.

A LDAP service implements the protocol. A directory that can be accessed via a LDAP service is called a LDAP directory.

For instance, let’s have a look at some part of the LDAP directory tree of an opsi server with LDAP backend (as shown by the Open Source tool JXplorer):

Figure 10.4. View of some part of an opsi LDAP tree

A LDAP search request is a query to a LDAP directory via a LDAP service. The response returns some content from the directory.

Basically the search request has to describe the path in the directory tree which leads to the interesting piece of information. The path is the distinguished name (dn), composed of the names of the nodes (the "relative distinguished names"), which build the path, for instance:

local/uib/opsi/generalConfigs/bonifax.uib.local

Since each node is conceived as an instance of some structural object class, the path description is usually given in the following form: with indication of the classes (and starting with the last path element) :

cn=bonifax.uib.local,cn=generalConfigs,cn=opsi,dc=uib,dc=local

The path in a query is not necessarily "complete", and not leading to a unique leaf of the tree. On the contrary, partial paths are common.

But even if the path descends to a unique leaf, the leaf may contain several values. Each node of the tree has one or more classes as attribute types. To each one or may values may be associated.

For a given query path, we therefore may be interested

in the node set whose elements – the so called LDAP objects – match the given path,

the set of attributes that belong the nodes,

and the values that are associated to all of them.

Obviously, handling the amount of possibly returned response information is the main challenge when dealing with LDAP searches.

The following section shows the documentation of a LDAPsearch roughly corresponding to the screenshot above as executed by opsi-winst/opsi-script.

There are several opsi-winst/opsi-script options to manage and reduce the complexity of the evaluation of such responses.

10.15.2. LDAPsearch Call Parameters

Two kinds of LDAPsearch parameters,

cache options

output options

are defined for the call of LDAPsearch section.

The cache options are:

/cache

/cached

/free

(no cache option)

If there is no cache option specified, the response of the LDAP search request is not saved for further usages.

By the /cache option, the response is cached for further evaluations, the /cached option refers to the last cached response which is reused instead of starting a new search, the /free option clears the cache explicitly (may only be useful for searches with extreme large responses).

The output options are:

/objects

/attributes

/values

(no output option)

The output options determine the String list that is produced when a LDAPsearch section is called via getReturnlistFromSection:

If no output option is specified the returned list is the complete LDAP response.

The options objects, attributes and values restrict the output to object, attribute or value lines of the LDAP response respectively.

Observe that in the produced lists the object an attribute belongs to is only identifiable if only one object is returned in the object list, and likewise the object and the attribute to which a value is subsumed are only identifiable if there is only attribute remaining in the attributes list.

Such the proceeding is, that the LDAPsearch is specified up to that degree, that at most one object and one attribute is returned. This can be checked by a count call on the objects and the attributes return list. Then any value found belongs to the dn and the attribute specified.

The repeated utilization of the same LDAP response can be done without relevant time costs by using the cache/cached options.

10.15.3. How to Narrow the Search

An example may show how we can narrow the search to pin down a specific result from a LDAP directory.

We start with the call of ldapsearch_generalConfigs as above, only adding the cache parameter.

By the function count (list) we can check if we succeeded with the narrowing of the search request. In most circumstances, we would like that its result be "1".

10.15.4. LDAPsearch Section Syntax

A LDAPsearch section comprises the specifications:

targethost:
The server hosting the LDAP directory (service) must be named.

user:
user name to be applied. Since 4.11.3.5

password:
user password to be applied. Since 4.11.3.5

targetport:
If the port of the LDAP service is not the default (389), it can be declared at this place. If the specification is missing, the default port is used.

dn:
Here, the distinguished name, the "search path", for the search request can be given.

typesonly:
Default "false", that is, values are retrieved.

filter:
A filter for LDAP search has a LDAP specific syntax that is not checked by opsi-winst/opsi-script. Default is "(objectclass=*)"

attributes:
A comma separated list of attribute names may be given. The default is to take any attribute.

10.15.5. Examples

A short and rather realistic example shall end this section:

$founditems$ be a StringList variable and $opsiClient$ a String variable. The call of getReturnlistFromSection fetches the results of the section ldapsearch_hosts. The following code fragment returns the unique result for $opsiDescription$ if it exists. It reports an error if the search produces an unexpected result:

For further examples watch the product opsi-script-test and there especially
$Flag_winst_ldap_search$ = "on"

Chapter 11. 64 Bit Support on Windows [W]

The opsi-winst/opsi-script is a 32 bit program. In order to make it easy for 32 bit programs to run on 64 bit systems there are special 32 bit areas in the registry as well in the file system. Some accesses from 32 bit programs will be redirected to these special areas to avoid access to areas that reserved for 64 bit programs.

A access to c:\windows\system32 will be redirected to c:\windows\syswow64

But a access to c:\program files will be not redirected to c:\program files (x86)

A registry access to [HKLM\software\opsi.org] will be redirected to [HKLM\software\wow6432node\opsi.org]

Therefore opsi-winst/opsi-script installs as 32 bit program scripts, that run on 32 bit system fine, on 64 bit system correct without any change.

For the installation of 64 bit programs some constants like %ProgramFilesDir% returns the wrong values. Therefore we have since opsi-winst/opsi-script 4.10.8 some new features:

Normally you may (and should) tell explicit to which place you want to write or from where you want to read. Here we have three variants:

32

explicit 32 bit

64

explicit 64 bit; if not on a 64 bi system like sysnative

SysNative

according to the architecture on which the script runs

Following this idea, we have some additional constants:

Table 11.1. Constants

Constant

32 Bit

64 Bit

%ProgramFilesDir%

c:\program files

c:\program files (x86)

%ProgramFiles32Dir%

c:\program files

c:\program files (x86)

%ProgramFiles64Dir%

c:\program files

c:\program files

%ProgramFilesSysnativeDir%

c:\program files

c:\program files

%ProgramFilesDir%

you should avoid this in future…

%ProgramFiles32Dir%

should be used in the context of installing 32 bit Software.

%ProgramFiles64Dir%

should be used in the context of installing 64 bit Software.

%ProgramFilesSysnativeDir%

should be used if you need architecture specific information

For a reading access to the different aereas of registry and filesystem we have now the following new functions:

GetRegistrystringvalue32

GetRegistrystringvalue64

GetRegistrystringvalueSysNative

FileExists32

FileExists64

FileExistsSysNative

The following functions have the possibility to control the access mode by a parameter (the default is here sysnative):

getRegistryValue

RegKeyExists

RegVarExists

powershellCall

A simple call to Registry-section results in writing to the 32 bit registry regions. Also a simple call to Files-section results in writing to the 32 bit file system regions.

For Registry, Files and Winbatch sections we have now the additional calling options:

/32Bit
This is the default. Any access will be redirected to the 32 bit regions.

/64Bit
Any access will be redirected to the 64 bit regions. If there are no 64 bit regions the architecture specific regions will be ussed.

/SysNative
Any access will be redirected to the architecture specific regions

For DosBatch, DosInAnIcon (ShellBatch, ShellInAnIcon) and Execwith you have to keep in mind that any modifiers has to separated by the keyword winst.
Example:

DosInAnIcon_do_64bit_stuff winst /64Bit

In addition to these opsi-winst/opsi-script functions, we copy at the installation of the opsi-client agent the (64 bit) file c:\windows\system32\cmd.exe to c:\windows\cmd64.exe. Using this cmd64.exe with ExecWith sections you may call any 64 bit operations on the command line.

12.3. Script for Installations in the Context of a Local Administrator

Sometimes it is necessary to run an installation script as an ordinary local user and not in the context of the opsi service. For example, there are installations that require a user context or use other services that are started after a user login.

MSI installations which seem to need a local user can sometimes be configured by the option ALLUSERS=1 to proceed without such a user:

In other case it is necessary to create a temporary administrative user in whose context the installation takes place. This can be done as follows:

Create a new product frame based on the product opsi-template-with-admin

Create a directory localsetup in the product directory (i.e. in install\productId).

Move all your installation files into the directory CLIENT_DATA\localsetup.

Make sure that your setup script at CLIENT_DATA\localsetup starts with a reboot call:

[Actions]
ExitWindows /Reboot

Edit at CLIENT_DATA\setup.ins the variables that are marked with: Please edit the following values.

The opsi-winst/opsi-script script template temporarily generates a user context, executes an installation in it, then removes it. Before using the template the following values are to be set adequately:

the value for the variable $Productname$

the value of the variable $ProductSize$

the value of the variable $LocalSetupScript$ (the name of your setup script)

The script proceeds as follows:

It creates a local administrator opsiSetupAdmin;

saves the autologon state;

inserts opsiSetupAdmin as autologon user;

copies the installation files to the client (as defined in $localFilesPath$); among them the installation script that is to be executed in the local user context;

creates a RunOnce entry in the registry that calls opsi-winst/opsi-script with the local script as argument;

reboots in order to make the registry change work;

when opsi-winst/opsi-script runs again, it calls an ExitWindows /ImmediateLogout, and the second scripting level begins to work:

By autologon , opsiSetupAdmin is logged on without user interaction.

Windows calls the RunOnce command, that is the opsi-winst/opsi-script call.

The opsi-winst/opsi-script script should now regularly proceed. But at its end, there must be a ExitWindows /ImmediateReboot command. Otherwise the desktop would of the administratrive user opsiSetupAdmin who is already logged at the moment would be accessible.

after the reboot, the main script works again cleaning everything (writing back the old autologon state, deleting the local setup files, removing the opsiSetupAdmin profile)

We call the two involved opsi-winst/opsi-script scripts master script and local script . The first one runs in a system service context, the second which does the specific software installation runs in the context of a local administrator.

Caution

If the local script requires internal reboots then the master script must be adapted to produce them. As long as the local script is not finished the master script hands over control to the local script by an ExitWindows /ImmediateLogout. Of course the RunOnce entry has to be created for each run. Since username and password for the autologon are removed at the beginning of the local script they have to be reset each time as well.

There is (since opsi 4.0.2-2) a direct access from the local script to the product properties.

There may be product installations by external setup program calls which change registry entries which are saved by the master script and usually written back at the end of the installation. In this case the master script must be adapted to avoid writing back.

The local script runs with an administrator logged in. You have to lock the keyboard when testing is done. Otherwise anybody sitting at the client could stop script execution and take over the session. Therefore the product has a product property debug which switches input locking and log level.

In order to avoid logging of passwords the loglevel is temporarily set to -2.

Important

Please do not use the script as printed below, but use the opsi product: opsi-template-with-admin.

To read the elements and get the values of all „Application“ nodes we may use these extracts of code:

[Actions]
DefStringList $list$
...
set $list$ = getReturnListFromSection ('XMLPatch_findProducts '+$TEMP$+'\test.xml')
for $line$ in $list$ do Sub_doSomething
[XMLPatch_findProducts]
openNodeSet
; Node „Collector“ is documentroot
documentroot
all_childelements_with:
elementname:"SoftwareList"
all_childelements_with:
elementname:"Application"
end
return elements
[Sub_doSomething]
set $escLine$ = EscapeString:$line$
; now we can work on the content of $escLine$

We encapsulate the retrieved Strings by setting their values as a whole into an variable via an EscapeString call. Since the loop variable %line% is not a common variable but behaves like a constant all special characters in it ( as < > $ % “ \' ) may cause difficulties.

'

12.7. Inserting a Name Space Definition Into a XML File

The opsi-winst/opsi-script XMLPatch section requires fully declared XML name spaces (as is postulated in the XML RFC). But there are XML configuration files which do not declare „obvious“ elements (and the interpreting programs insist that the file looks this way). Especially patching the lots of XML/XCU configuration files of OpenOffice.org proved to be a hard job. For solving this task, A. Pohl (many thanks!) the functions XMLaddNamespace and XMLremoveNamespace. Its usage is demonstrated by the following example:

DefVar $XMLFile$
DefVar $XMLElement$
DefVar $XMLNameSpace$
set $XMLFile$ = "D:\Entwicklung\OPSI\winst\Common.xcu3"
set $XMLElement$ = 'oor:component-data'
set $XMLNameSpace$ = 'xmlns:xml="http://www.w3.org/XML/1998/namespace"'
if XMLAddNamespace($XMLFile$,$XMLElement$, $XMLNameSpace$)
set $NSMustRemove$="1"
endif
;
; now the XML Patch should work
; (commented out since not integrated in this example)
;
; XMLPatch_Common $XMLFile$
;
; when finished we rebuild the original format
if $NSMustRemove$="1"
if not (XMLRemoveNamespace($XMLFile$,$XMLElement$,$XMLNameSpace$))
LogError "XML-Datei konnte nicht korrekt wiederhergestellt werden"
isFatalError
endif
endif

Please observe that the XML file must be formatted such that the element tags do not contain line breaks.

12.8. Finds out if a script is currently running in the context of a particular event

The opsiclientd determines and knows which event is currently active. opsi-script can be used by means of an opsiservicecall
And thus connect with the opsiclientd querying the corresponding events:

asciidoc is a base format to create documents in different formats like html, pdf, epub, docbook, ...

The documentation is created from informations, that are extracted from the source code. From the source code opsi-doc-generator knows the definitions of opsi-script defined functions and can get the informazion from there.
For additional information there may be special markers in comment lines which hold additional information on the level of file, function and parameter.

You will find this programs for Linux and Windows as opsi packages in the contribute area on download.uib.de

14.3. opsi-doc-generator marker

There are three different levels where information can be found in a source file:

file

function (may be more than one in a file)

function parameter (may be more than one in a function)

Every marker starts with the language specific comment char (opsiscript=;) followed by the the @ char and the marker identifier string.

Every allowed marker can occour never, once or multiple time on a level. If a marker occour multiple times, all lines of this marker are concatenated

After a marker one or more space chars have to be used before the information start

opsi-script markers allowed on the file level

;@author

;@email

;@date

;@copyright

;@version

;@filedesc Description of file

opsi-script markers allowed on the function level

;@author Author (if absent author of file is used)

;@email eMail address (if absent eMail of file is used)

;@date Date (if absent date of file is used)

;@copyright copyright (if absent copyright of file is used)

;@version version (if absent version of file is used)

;@Description Description of function

;@Returns Return value of function

;@OnError What happens in the case of an error

;@SpecialCase What happens in known special unexpected cases like empty input, no network, and so son

;@Requires

;@References The name of an other function in this file that are related to this function. only one per line. For multiple references use multiple lines

;@Links

;@Example An example for the use of this function.
Examples are in most cases multiline with idents. The start of the information in the first example line defines the base ident. Idents have to be done with space chars only (no tabs).

opsi-script markers allowed on the function parameter level

;@ParamDesc_<praram name> Description of the parameter <praram name>

;@ParamAdvice_<praram name> Advice to the parameter <praram name>. That may be for example restrictions for valid values.

Chapter 15. opsi-winst Tutorial (1.0.0)

15.1. Introduction

This tutorial should help you to learn some advanced features (e.g. string lists) of the opsi-winst script language.

Before we start some hints:

you should always use opsi script constants if they aplicable. For example use %system% instead of c:\windows\system32.

You shold use the opsi-winst manuals for further description of the mentioned script commands:

opsi-winst manual

opsi-winst reference card

You should use the opsi product opsi-script-test as a running reference script which is calling (nearly) every opsi-winst command.

15.2. Creating opsi-winst scripts

You may use every text editor. We recommend to use the jedit editor with integrated opsi-winst syntax highlighting.

For testing opsi-winst scripts it is a good idea to run them from an interactive started opsi-winst. (see: getting-started for more details)

15.2.1. 1. Lection

In the first lection you should just list all files of your c:\windows\system32 directory.

You should use the following opsi-winst functions:

DosInAnIcon

15.2.2. 2. Lection

Extend your script of the first lection by assingning the output of your DosInAnIcon call to a string list

You should use the following opsi-winst functions:

DefStringlist

getOutStreamFromSection

setloglevel = 7

15.2.3. 3. Lection

You should determine the number of dll files in your c:\windows\system32 and write this number to the log file.

Extend your script of the second lection by extracting from your file list a new list which contains only the dll files and count them.

You should use the following opsi-winst functions:

getListContaining

count

comment

15.2.4. 4. Lection

Is there a kernel32.dll at your c:\windows\system32 and which size has it ?

Extend your script of the third lection by extracting from your file list a new string which contains only the directory listing entry of the kernel32.dll. Then extract the size entry from this string.

You should use the following opsi-winst functions:

TakeFirstStringContaining

SplitStringOnWhiteSpace

TakeString

15.2.5. 5. Lection

Which kernel32.dll is bigger the 32Bit or the 64Bit variant ?

Extend your script of the fourth lection by running in different mode for the 32 Bit and 64 Bit part.

Documentation of local function isMsiExitcodeFatal

Evaluates the given $exitcode$ as MSI Error and
and gives back a resulting error message on $ErrorString$
If the Error require a reboot the given parameter $allowRebootRequest$
is used to decide if a ExitWindows /Reboot is called or not

Parameter: $exitcode$

Type: String - Calltype: CallByValue

Parameter $exitcode$ Description:
Exit code given by msiexec

Parameter: $allowrebootrequest$

Type: String - Calltype: CallByValue

Parameter $allowrebootrequest$ Description:
Should we call ExitWindows /Reboot if the exit code require this (true or false)

Parameter: $errorstring$

Type: String - Calltype: CallByReference

Parameter $errorstring$ Description:
Here we get the error string that belongs to the given exit code

Returns: Returns string "true" if the exit code points to a critical error.
Returns string "true" if the exit code is not a number (not valid).
Returns string "false" if the exit code is valid but not critical.

Documentation of local function isMsExitcodeFatal_short

Evaluates the given $exitcode$ as MS Error and
and gives back a resulting error message on $ErrorString$
if the exit code is well known.
For full list of exit dodes use isMsiExitcodeFatal
If the Error require a reboot the given parameter $allowRebootRequest$
is used to decide if a ExitWindows /Reboot is called or not

Parameter: $exitcode$

Type: String - Calltype: CallByValue

Parameter $exitcode$ Description:
Exit code given by ms

Parameter: $allowrebootrequest$

Type: String - Calltype: CallByValue

Parameter $allowrebootrequest$ Description:
Should we call ExitWindows /Reboot if the exit code require this (true or false)

Parameter: $errorstring$

Type: String - Calltype: CallByReference

Parameter $errorstring$ Description:
Here we get the error string that belongs to the given exit code

Returns: Returns string "true" if the exit code points to a critical error.
Returns string "true" if the exit code is not a number (not valid).
Returns string "false" if the exit code is valid but not critical.

Documentation of local function isAdvancedMsiExitcodeFatal

Please note: Import complete file uib_exitcode (not only isAdvancedMsiExitcodeFatal)
Evaluates the given $exitcode$ as AdvancedMsi Error and
and gives back a resulting error message on $ErrorString$
It is also checked if the exit code is one from the embedded msi.
There for is isMsiExitcodeFatal used
If the Error require a reboot the given parameter $allowRebootRequest$
is used to decide if a ExitWindows /Reboot is called or not

Parameter: $exitcode$

Type: String - Calltype: CallByValue

Parameter $exitcode$ Description:
Exit code given by AdvancedMsi

Parameter: $allowrebootrequest$

Type: String - Calltype: CallByValue

Parameter $allowrebootrequest$ Description:
Should we call ExitWindows /Reboot if the exit code require this (true or false)

Parameter: $errorstring$

Type: String - Calltype: CallByReference

Parameter $errorstring$ Description:
Here we get the error string that belongs to the given exit code

Returns: Returns string "true" if the exit code points to a critical error.
Returns string "true" if the exit code is not a number (not valid).
Returns string "false" if the exit code is valid but not critical.

Documentation of local function isInnoExitcodeFatal

Evaluates the given $exitcode$ as Inno Error and
and gives back a resulting error message on $ErrorString$
If the Error require a reboot the given parameter $allowRebootRequest$
is used to decide if a ExitWindows /Reboot is called or not

Parameter: $exitcode$

Type: String - Calltype: CallByValue

Parameter $exitcode$ Description:
Exit code given by Inno

Parameter: $allowrebootrequest$

Type: String - Calltype: CallByValue

Parameter $allowrebootrequest$ Description:
Should we call ExitWindows /Reboot if the exit code require this (true or false)

Parameter: $errorstring$

Type: String - Calltype: CallByReference

Parameter $errorstring$ Description:
Here we get the error string that belongs to the given exit code

Returns: Returns string "true" if the exit code points to a critical error.
Returns string "true" if the exit code is not a number (not valid).
Returns string "false" if the exit code is valid but not critical.

Documentation of local function isInstallshieldExitcodeFatal

Please note: Import complete file uib_exitcode (not only isAdvancedMsiExitcodeFatal)
Evaluates the given $exitcode$ as Installshield Error and
and gives back a resulting error message on $ErrorString$
It is also checked if the exit code is one from the embedded msi.
There for is isMsiExitcodeFatal used
If the Error require a reboot the given parameter $allowRebootRequest$
is used to decide if a ExitWindows /Reboot is called or not

Parameter: $exitcode$

Type: String - Calltype: CallByValue

Parameter $exitcode$ Description:
Exit code given by Installshield

Parameter: $allowrebootrequest$

Type: String - Calltype: CallByValue

Parameter $allowrebootrequest$ Description:
Should we call ExitWindows /Reboot if the exit code require this (true or false)

Parameter: $errorstring$

Type: String - Calltype: CallByReference

Parameter $errorstring$ Description:
Here we get the error string that belongs to the given exit code

Returns: Returns string "true" if the exit code points to a critical error.
Returns string "true" if the exit code is not a number (not valid).
Returns string "false" if the exit code is valid but not critical.

Documentation of local function isNsisExitcodeFatal

Evaluates the given $exitcode$ as Nsis Error and
and gives back a resulting error message on $ErrorString$
If the Error require a reboot the given parameter $allowRebootRequest$
is used to decide if a ExitWindows /Reboot is called or not

Parameter: $exitcode$

Type: String - Calltype: CallByValue

Parameter $exitcode$ Description:
Exit code given by Nsis

Parameter: $allowrebootrequest$

Type: String - Calltype: CallByValue

Parameter $allowrebootrequest$ Description:
Should we call ExitWindows /Reboot if the exit code require this (true or false)

Parameter: $errorstring$

Type: String - Calltype: CallByReference

Parameter $errorstring$ Description:
Here we get the error string that belongs to the given exit code

Returns: Returns string "true" if the exit code points to a critical error.
Returns string "true" if the exit code is not a number (not valid).
Returns string "false" if the exit code is valid but not critical.