opsi-script reference card (4.12.13)
For Windows [W], Linux [L] and MacOS [M]
Global text constants
System directories
System directories [W]:
%ProgramFilesDir%
: 'c:\program files (x86)' at 64 Bit
%ProgramFiles32Dir%
: 'c:\Program Files (x86)' at 64 Bit //since 4.10.8
%ProgramFiles64Dir%
: 'c:\program files' at 64 Bit //since 4.10.8
%ProgramFilesSysnativeDir%
: 'c:\program files' at 64 Bit //since 4.10.8
%Systemroot%
: 'c:\windows'
%System%
: 'c:\windows\system32' at 32/64 Bit
%Systemdrive%
: 'c:'
%ProfileDir%
:
NT5: 'c:\Documents and Settings'
NT6: 'C:\users'
Common (AllUsers) directories [W]:
%AllUsersProfileDir%
or %CommonProfileDir%
:
NT5: 'c:\Documents and Settings\All Users'
NT6: 'C:\Users\Public'
%CommonStartMenuPath%
or %CommonStartmenuDir%
:
NT5: 'c:\Documents and Settings\All Users\Startmenu'
NT6: 'C:\ProgramData\Microsoft\Windows\Start Menu'
%CommonAppdataDir%
:
NT5: 'c:\Documents and Settings\All Users\Application Data'
NT6: 'C:\ProgramData'
%CommonDesktopDir%
NT5: 'c:\Documents and Settings\All Users\Desktop'
NT6: 'C:\Users\Public\Desktop'
%CommonStartupDir%
NT5: 'c:\Documents and Settings\All Users\Autostart'
NT6: 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp'
%CommonProgramsDir%
NT6: 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs'
see also : Common (AllUsers) directories [W]
Default User directories [W]:
%DefaultUserProfileDir%
: 'C:\Users\Default' //since 4.11.1.1
see also : Default User Directory [W]
Current user directories [W]:
User is the logged in user or given by /usercontext.
%AppdataDir%
or %CurrentAppdataDir%
: //since 4.10.8.13
NT6: 'c:\Users\%USERNAME%\Appdata\Roaming'
%CurrentStartmenuDir%
//since 4.10.8.13
'C:\Users\<user name>\AppData\Roaming\Microsoft\Windows\Start Menu'
%CurrentDesktopDir%
//since 4.10.8.13
'C:\Users\<user name>\Desktop'
%CurrentStartupDir%
//since 4.10.8.13
'C:\Users\<user name>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup'
%CurrentProgramsDir%
//since 4.10.8.13
'C:\Users\<user name>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs'
%CurrentSendToDir%
//since 4.10.8.13
'C:\Users\<user name>\AppData\Roaming\Microsoft\Windows\SendTo'
%CurrentProfileDir%
//since 4.11.2.1
'C:\Users\<user name>'
/AllUserProfiles directory constants [W/L/M]:
%UserProfileDir%
or
%CurrentProfileDir%
// since 4.11.2.1
NT5: 'c:\Documents and Settings\%USERNAME%'
NT6: 'c:\users\%USERNAME%'
opsi-script Path and Directories [W/L/M]:
%ScriptPath% or %ScriptDir%
%RealScriptPath%
(since 4.12.4.21)
%ScriptDrive%
%OpsiscriptDir%
(since 4.12.3.6), %WinstDir%
%OpsiscriptVersion%
(since 4.12.3.6), %WinstVersion%
(since 4.10.8.3)
%opsiscriptProcname%
(since 4.12.4.35)
%Logfile%
%opsiScriptHelperPath%
'%ProgramFiles32Dir%\opsi.org\opsiScriptHelper\lib' // since 4.11.3.2
%opsiTmpDir%
: 'c:\opsi.org\tmp' // since 4.11.4.3
%opsiUserTmpDir%
: 'c:\opsi.org\usertmp' // since 4.12.4.37
%opsiLogDir%
: 'c:\opsi.org\log' // since 4.11.4.3
%opsidata%
: 'c:\opsi.org\data' // since 4.12.0.12
%opsiapplog%
: 'c:\opsi.org\applog' // since 4.12.0.12
see also : opsi-script Path and Directory [W/L/M]
Network informations [W/L/M]:
%Host%
: value of environment variable HOST.
%PCName%
: value of environment variable PCNAME, or if absent of COMPUTERNAME.
%Username%
: Name of actual user.
%IPName%
: The dns name of the pc. Usually identical with the netbios name and therefore with %PCName%
besides that the netbios names uses to be uppercase.
%IPAddress%
: may be the IP-Address of the machine. Use funktion GetMyIpByTarget()
instead.
see also : GetMyIpByTarget
see also : Network Information [W/L/M]
Service Data [W/L/M]
%HostID%
: FQDN of the client in opsi service context, otherwise the computer name
%FQDN%
: FQDN in network context
%opsiserviceURL%
%opsiServer%
%opsiDepotId%
//since 4.11.4
%opsiserviceUser%
FQDN used for the connection to the opsi-config-server
%opsiserviceClientId%
: command line option /clientid
%opsiservicePassword%
%installingProdName%
: productid //since 4.10.8
%installingProdVersion%
: product version //since 4.10.8
%installingProduct%
: productid (deprecated)
see also : Data for and from opsi service [W/L/M]
Functions to handle constants [W/L/M]
replaceOpsiConstants(
<string list> ) : stringlist
//since 4.12.3.6 [W/L/M]
see also : replaceOpsiConstants_list
replaceOpsiConstants(
<string> ) : string
//since 4.12.3.6 [W/L/M]
see also : replaceOpsiConstants_string
In Primary Sections
Kinds of Primary Sections [W/L/M]:
[Initial]
[Actions]
[sub
<identifier> ]
sub
<file name>
[ProfileActions]
[W]
opsi-script control [W/L/M]:
encoding=
<encoding> // (default is system encoding) since 4.11.4.2
see also : encoding
LogLevel
(deprecated)
see also : Specification of Logging Level [W/L/M]
SetLogLevel
= <number> or SetLogLevel
= <string> // (default=6)
see also : SetLogLevel
SetLogLevel = 7
SetLogLevel = "7"
ExitOnError
= <boolean value> // (default=false)
see also : ExitOnError
ScriptErrorMessages =
<boolean value> // (default=true)
see also : ScriptErrorMessages
see also : Central configuration via opsi Configs
FatalOnSyntaxError =
<boolean value> // (default=true) since 4.11.3.2
see also : FatalOnSyntaxError
FatalOnRuntimeError =
<boolean value> // (default=false) since 4.11.3.2
see also : FatalOnRuntimeError
AutoActivityDisplay =
<boolean value> // (default=false); if true shows a marquee (endless) progressbar while winbatch/ShellScript sections are . //since 4.11.4.7
see also : AutoActivityDisplay
see also : Central configuration via opsi Configs
forceLogInAppendMode =
<boolean value> // (default=false); if true, log will be send in append mode . //since 4.12.3.6
see also : forceLogInAppendMode
Message
<string> or Message
= <const string>
see also : Message
ShowMessageFile
<string>
see also : ShowMessageFile
ShowBitMap
[<file name>] [<sub title>]
see also : ShowBitMap
comment
<string> or comment
= <const string>
see also : comment
LogError
<string> or LogError
= <const string>
see also : LogError
LogWarning
<string> or LogWarning
= <const string>
see also : LogWarning
includelog
<file name> <tail size> //since 4.11.2.1 [W/L/M]
see also : includelog
includelog
<file name> <tail size> [<encoding>] //since 4.11.4.1 [W/L/M]
see also : includelog
includelog "%Scriptpath%\test-files\10lines.txt" "5"
SetConfidential
<secret string> //since 4.11.3.5 [W/L/M]
see also : SetConfidential
asConfidential(
<secret string expression> ) : string
//since 4.12.0.16 [W/L/M]
see also : asConfidential_str
asConfidential(
<secret stringlist expression> ) : stringlist
//since 4.12.4.15 [W/L/M]
see also : asConfidential_list
Pause
<string> or Pause
= <const string>
see also : Pause
Stop
<string> or stop
= <const string>
see also : Stop
include_insert
<file name> // since 4.11.3
see also : include_insert
include_append
<file name> // since 4.11.3
see also : include_append
NormalizeWinst
// (set normal window state) since 4.11.3
see also : NormalizeWinst
IconizeWinst
// (set minimized window state)
see also : IconizeWinst
MaximizeWinst
// (set maximized window state) // since 4.11.5.1
see also : MaximizeWinst
RestoreWinst
// (restore last window state)
see also : RestoreWinst
SetSkinDirectory
<path to skin.ini> // since 4.11.3.5
see also : SetSkinDirectory
runningInWanMode
: boolean //since 4.12.4.17 [W/L/M]
see also : runningInWanMode
reloadProductList
//since 4.12.6.1 [W/L/M]
see also : reloadProductList
Variables [W/L/M]:
Strings
DefVar
<variable name> // since 4.12.4.32 also possible:
DefVar
<variable name> [= <inital value>]
Set
<variable name> =
<value>
see also : String (or Text) Variables [W/L/M]
Stringlists
DefstringList
<variable name>
; since 4.12.4.32 also possible:
DefstringList
<variable name> [= <inital value>]
see also : Stringlist Variables [W/L/M]
Functions
String functions
Important
GetOS
// 'Linux' or 'Windows_NT' [W/L/M]
see also : GetOS
getLinuxDistroType
// 'debian' or 'redhat' or 'suse' (see getLinuxVersionMap
) [L]
see also : getLinuxDistroType
GetMsVersionInfo
//Windows Version Information [W]
see also : GetMsVersionInfo
GetMsVersionName
//Windows Version Information [W]
see also : GetMsVersionName
GetSystemType
//OS Architecture ("64 Bit System" or "x86 System") [W/L/M]
see also : GetSystemType
getOSArchitecture
// OS Architecture (x86_32 / x86_64/ arm_64) //since 4.12.4.17 [W/L/M]
see also : getOSArchitecture
getRegistryValue(
<keystr>, <varstr> )
: string //since 4.12.0.16 [W]
<access str> = one of 32bit, 64bit, sysnative ; default sysnative
see also : getRegistryValue
GetRegistrystringvalue ("[key] var")
: string [W]
see also : GetRegistrystringvalue
GetRegistryStringValue32 ("[key] var")
: string //since 4.10.8 [W]
see also : GetRegistryStringValue32
GetRegistryStringValue64 ("[key] var")
: string //since 4.10.8 [W]
see also : GetRegistryStringValue64
GetRegistryStringValueSysNative ("[key] var")
: string //since 4.10.8 [W]
see also : GetRegistryStringValueSysNative
GetValueFromInifile (
<file path>, <section>, <key>, <default value>[, <encoding>])
: string [W/L/M]
see also : GetValueFromInifile
GetProductProperty (
<PropertyName>, <DefaultValue> )
[W/L/M]
see also : GetProductProperty
GetConfidentialProductProperty (
<PropertyName>, <DefaultValue> )
//since 4.11.5.2 [W/L/M]
see also : GetConfidentialProductProperty
trim(
<string> )
[W/L/M]
see also : trim
lower(
<string> )
[W/L/M]
see also : lower
upper(
<string> )
[W/L/M]
see also : upper
unquote(
<string>,<quote-string> )
//since 4.11.2.1 [W/L/M]
see also : unquote
unquote2(
<string>,<quote-string> )
//since 4.11.5.2 [W/L/M]
see also : unquote2
stringReplace(
<string>, <oldPattern>, <newPattern> )
//since 4.11.3 [W/L/M]
see also : stringReplace
strLength(
<string> )
//since 4.11.3 [W/L/M]
see also : strLength
strPos(
<string>, <sub string> )
//since 4.11.3 [W/L/M]
see also : strPos
strPart(
<string>, <start pos>, <number of chars> )
//since 4.11.3 [W/L/M]
see also : strPart
getValue(
<key string>, <hash string list> )
[W/L/M]
see also : getValue
getValueBySeparator(
<key string>,<separator string>,<hash string list> )
//since 4.11.2.1 [W/L/M]
see also : getValueBySeparator
setValueByKey(
<key>, <value>, <targetlist> )
[W/L/M]
see also : prim-section.adoc#setValueByKey
getValueFromFile(
<key string>, <file name> )
//since 4.11.4.4 [W/L/M]
see also : getValueFromFile
getValueFromFileBySeparator(
<key string>,<separator string>,<file name> )
//since 4.11.4.4 [W/L/M]
see also : getValueFromFileBySeparator
getLastExitCode : string (exitcode)
[W/L/M]
see also : getLastExitCode
Special: License Management
DemandLicenseKey(
poolId [, productId [,windowsSoftwareId]] )
set $mykey$ = DemandLicenseKey ("", "office2007")
see also : DemandLicenseKey
FreeLicense (
poolId [, productId [,windowsSoftwareId]] )
set $result$ = FreeLicense("", "office2007")
see also : FreeLicense
Special: Usercontext / loginscripts [W]:
GetUserSID(
<Windows Username> )
see also : GetUserSID
GetLoggedInUser
//since 4.11.1.2
see also : GetLoggedInUser
GetUsercontext
//since 4.11.1.2
see also : getLastExitCode
GetScriptMode
possible values 'Machine','Login' //since 4.11.2.1
see also : GetUsercontext
saveVersionToProfile
- save productversion-packageversion to local profile //since 4.11.2.1
see also : saveVersionToProfile
readVersionFromProfile
: string - read productversion-packageversion from local profile //since 4.11.2.1
see also : readVersionFromProfile
scriptWasExecutedBefore
: boolean - is true if saved and running productversion-packageversion are identical //since 4.11.2.1
see also : scriptWasExecutedBefore
Other
GetHostsName (
<hostaddress> )
[W/L/M]
see also : GetHostsName
GetHostsAddr (
<hostname> )
[W/L/M]
see also : GetHostsAddr
ExtractFilePath (
<path> )
[W/L/M]
see also : ExtractFilePath
calculate(
<arithmetic string expression> )
// since 4.11.3.5 : knows: +-*/()
[W/L/M]
see also : calculate
DecStrToHexStr (
<decstring>, <hexlength> )
[W/L/M]
see also : DecStrToHexStr
HexStrToDecStr (
<hexstring> )
[W/L/M]
see also : HexStrToDecStr
base64EncodeStr(
<string> )
[W/L/M]
see also : base64EncodeStr
base64DecodeStr(
<string> )
[W/L/M]
see also : base64DecodeStr
convert2Jsonstr(
<string> )
//since 4.10.8.3
RandomStr
[W/L/M]
see also : RandomStr
RandomStrWithParameters
[W/L/M]
see also : RandomStrWithParameters
RandomIntStr(
<number str> ) : string
[W/L/M]
see also : RandomIntStr
CompareDotSeparatedStrings(
<string1>, <string2> ) : string
[W/L/M]
see also : CompareDotSeparatedStrings_str
CompareDotSeparatedNumbers(
<string1>, <string2> ) : string
[W/L/M]
see also : CompareDotSeparatedNumbers_str
EnvVar (
<environment variable> )
[W/L/M]
see also : EnvVar
ParamStr
[W/L/M]
see also : ParamStr
getDiffTimeSec
(Time in seconds since last marktime) //since 4.11.3 [W/L/M]
see also : getDiffTimeSec
SidToName(
<well known sid> )
//since 4.11.3: gives localized name of the sid [W]
see also : SidToName
GetMyIpByTarget(
<target ip addr> ) : string
//since 4.11.3.2 /4.11.6 [W/L/M]
see also : GetMyIpByTarget
GetIpByName(
<ip addr / ip name> )
//since 4.11.3.2 [W/L/M]
see also : GetIpByName
reencodestr(
<str>, <from>, <to> )
//since 4.11.4.2 [W/L/M]
see also : reencodestr
strLoadTextFile (
<filename> )
//since 4.11.4.6 [W/L/M]
see also : strLoadTextFile
strLoadTextFileWithEncoding (
<filename> , <encoding> )
//since 4.11.4.6 [W/L/M]
see also : strLoadTextFileWithEncoding
GetShortWinPathName(<longpath string>)
//since 4.11.5.2 [W]
see also : GetShortWinPathName
stringinput(
< message str>,< boolstr confidential> ) : string
//since 4.12.1.2 [W/L/M]
see also : stringinput
which(
<command in path> ) : string
(command with path) //since 4.12.3.6 [W/L/M]
see also : which
replaceOpsiConstants(
<string> ) : string
//since 4.12.3.6 [W/L/M]
see also : replaceOpsiConstants_string
ReadTOMLFile(
<TOMLfilePath: String> ) : String
//since 4.12.5.0 [W/L/M]
see also : ReadTOMLFile
GetTOMLAsString(
<TOMLcontents: String> ) : String
//since 4.12.5.0 [W/L/M]
see also : GetTOMLAsString
GetTOMLTableAsString(
<TOMLcontents: String> , <table name : String> ) : String
//since 4.12.5.0 [W/L/M]
see also : GetTOMLTableAsString
GetValueFromTOML(
<TOMLcontents: String> , <keyPath: String> , <defaultValue: String> ) : String
//since 4.12.5.0 [W/L/M]
see also : GetValueFromTOML
ModifyTOML(
<TOMLcontents: String> , <command: String> , <keyPath: String> , <value: String> ) : String
//since 4.12.5.0 [W/L/M]
see also : ModifyTOML
DeleteTableFromTOML(
<TOMLcontents: String> , <tablePath: String> ) : String
//since 4.12.5 [W/L/M]
see also : DeleteTableFromTOML
ConvertTOMLtoJSON(
<TOMLcontents: String> ) : String
//since 4.12.5.0 [W/L/M]
see also : ConvertTOMLtoJSON
Deprecated
GetNtVersion
Deprecated - please use GetMsVersionInfo
[W]
see also : GetMsVersionInfo
IniVar (
<key> )
: (deprecated; use GetProductProperty) [W]
see also : GetProductProperty
SubstringBefore (
<string1>, <string2> )
(deprecated; use splitString
/ takestring
) [W/L/M]
see also : splitString
String list functions
Important
splitString (
<string1>, <string2> )
[W/L/M]
set $list1$ = splitString ("\\server\share\dir","\")
see also : splitString
splitStringOnWhiteSpace (
<string> )
[W/L/M]
see also : splitStringOnWhiteSpace
loadTextFile (
<file name> )
[W/L/M]
see also : loadTextFile
loadUnicodeTextFile (
<file name> )
[W]
see also : loadUnicodeTextFile
loadTextFileWithEncoding(
<file name> ,
<encoding> )
//since 4.11.5 [W/L/M]
see also : loadTextFileWithEncoding
composeString (
<string list>, <Link> )
[W/L/M]
see also : composeString
takeString (
<index>, <list> )
[W/L/M]
see also : takeString
setStringInListAtIndex(
<newstring>,<list>,<indexstr> ) : stringlist
//since 4.11.6 [W/L/M]
see also : setStringInListAtIndex
takeFirstStringContaining(
<list>,<search string> )
[W/L/M]
see also : takeFirstStringContaining
getOutStreamFromSection (
<dos section name> )
[W/L/M]
set $list$= getOutStreamFromSection ('ShellScript_try')
see also : getOutStreamFromSection
shellCall (
<command string> ) : stringlist (output)
//since 4.11.4.2 [W/L/M]
set $list$= shellCall('net start')
see also : shellCall_list
getReturnListFromSection (
<xml section name> )
[W/L/M]
see also : getReturnListFromSection
getListContaining(
<list>,<search string> )
[W/L/M]
see also : getListContaining
getListContainingList(
<list1>,<list2> )
//since 4.11.3.7 [W/L/M]
see also : getListContainingList
count (
<list> )
[W/L/M]
see also : count
emptylist (
<list> )
//since 4.11.3.7 [W/L/M]
see also : emptylist
for %
<identifier> % in
<list> do
<one statement | sub section> [W/L/M]
for %s% in $list1$ do sub_test_string
see also : forInDo
GetProcessList
//since 4.11.1.2; gives list of exename;pid;dom/user [W/L/M]
see also : GetProcessList
getProductPropertyList(
<propname>,<default value> )
//since 4.11.3 [W/L/M]
see also : getProductPropertyList
getRegistryKeyList32(
<regkey> )
//since 4.11.3 [W]
see also : getRegistryKeyList32
getRegistryKeyList64(
<regkey> )
//since 4.11.3 [W]
see also : getRegistryKeyList64
getRegistryKeyListSysnative(
<regkey> )
//since 4.11.3 [W]
see also : getRegistryKeyListSysnative
getRegistryKeyList(
<regkey>, <access str> )
//since 4.12.5.0 [W]
see also : getRegistryKeyList
getRegistryVarList32(
<regkey> )
//since 4.11.3 [W]
see also : getRegistryVarList32
getRegistryVarList64(
<regkey> )
//since 4.11.3 [W]
see also : getRegistryVarList64
getRegistryVarListSysnative(
<regkey> )
//since 4.11.3 [W]
see also : getRegistryVarListSysnative
getRegistryVarList(
<regkey>, <access str> )
//since 4.12.5.0 [W]
see also : getRegistryVarList
getProfilesDirList
//since 4.11.3.2 [W/L/M]
see also : getProfilesDirList
listFiles (
<Path>, <Searchmask> , <SearchSubDirectories>[, <Redirection>]) : stringlist
//since 4.12.3 [W/L/M]
Set $Filelist$ = listFiles("C:\windows\system32","*.ico;*.dll","False","64bit")
see also : listFiles
replaceOpsiConstants(
<string list> ) : stringlist
//since 4.12.3.6 [W/L/M]
see also : replaceOpsiConstants_list
Infomaps
GetLocaleInfoMap
[W]
see also : GetLocaleInfoMap
GetMSVersionMap
[W]
see also : GetMSVersionMap
getLinuxVersionMap
//since 4.11.4 [L]
keys are (example):
Distributor ID=Ubuntu
Description=Ubuntu 12.04.2 LTS
Release=12.04
Codename=precise
kernel name=Linux
node name=detlefvm05
kernel release=3.2.0-40-generic-pae
kernel version=#64-Ubuntu SMP Mon Mar 25 21:44:41 UTC 2013
machine=i686
processor=athlon
hardware platform=i386
operating system=GNU/Linux
see also : getLinuxVersionMap
getFileInfoMap(
<file name> )
[W]
see also : getFileInfoMap
getProductMap
// since 4.11.2.4 [W/L/M]
keys are: id, name, description, advice, productversion, packageversion, priority, installationstate, lastactionrequest, lastactionresult, installedversion, installedpackage, installedmodificationtime,actionrequest
see also : getProductMap
getRegistryVarMap32(
<regkey> )
//since 4.11.3 [W]
see also : getRegistryVarMap32
getRegistryVarMap64(
<regkey> )
//since 4.11.3 [W]
see also : getRegistryVarMap64
getRegistryVarMapSysnative(
<regkey> )
//since 4.11.3 [W]
see also : getRegistryVarMapSysnative
getRegistryVarMap(
<regkey>, <access str> )
//since 4.12.5.0 [W]
see also : getRegistryVarMap
getHWBiosInfoMap
//since 4.11.4 [W/L/M]
see also : getHWBiosInfoMap
editmap(
<strlist> ) : stringlist
//since 4.12.1.2 [W/L/M]
see also : editmap
Other
createStringList (
<string0>, <string1> ,… )
[W/L/M]
set $list1$ = createStringList ('a','b')
see also : createStringList
reverse (
<list> )
[W/L/M]
see also : reverse
getSectionNames(
<ini-file> )
[W/L/M]
see also : getSectionNames
retrieveSection (
<section name> )
[W/L/M]
see also : retrieveSection
getSubList (
<start index> : <end index>, <list> )
[W/L/M]
see also : getSubList
getSubListByMatch (
<search string>, <target list> )
:stringlist //since 4.12.0.14 [W/L/M]
see also : getSubListByMatch_sl
getSubListByMatch (
<search list>, <target list> )
:stringlist //since 4.12.0.14 [W/L/M]
see also : getSubListByMatch_ll
getSubListByContaining (
<search string>, <target list> )
:stringlist //since 4.12.0.14 [W/L/M]
see also : getSubListByContaining_sl
getSubListByContaining (
<search list>, <target list> )
:stringlist //since 4.12.0.14 [W/L/M]
see also : getSubListByContaining_ll
getSubListByKey (
<search string>, <target list> )
:stringlist //since 4.12.0.14 [W/L/M]
see also : getSubListByKey_sl
getSubListByKey (
<search list>, <target list> )
:stringlist //since 4.12.0.14 [W/L/M]
see also : getSubListByKey_ll
getKeyList (
<list> )
:stringlist //since 4.12.0.14 [W/L/M]
see also : getKeyList
addtolist(
<list>,<string> )
//since 4.10.8 [W/L/M]
see also : addtolist
addListToList(
<dest list>,<src list> )
//since 4.10.8 [W/L/M]
see also : addListToList
reencodestrlist(
<list>, <from>, <to> )
//since 4.11.4.2 [W/L/M]
see also : reencodestrlist
removeFromListByContaining(
<search string> ,
<target list> ) : stringlist
//since 4.11.5.1 [W/L/M]
see also : removeFromListByContaining_str
removeFromListByContaining(
<search list> ,
<target list> ) : stringlist
//since 4.11.5.1 [W/L/M]
see also : removeFromListByContaining_list
removeFromListByMatch(
<searchstring>,<target list> ) : stringlist
//since 4.11.6 [W/L/M]
see also : removeFromListByMatch
LoadTOMLFile(
<TOMLfilePath: String> ) : StringList
//since 4.12.5 [W/L/M]
see also : LoadTOMLFile
GetTOMLAsStringList(
<TOMLcontents: String> ) : StringList
//since 4.12.5 [W/L/M]
see also : GetTOMLAsStringList
GetTOMLKeys(
<TOMLcontents: String> ) : StringList
//since 4.12.5 [W/L/M]
see also : GetTOMLKeys
GetTOMLTableNames(
<TOMLcontents: String> ) : StringList
//since 4.12.5 [W/L/M]
see also : GetTOMLTableNames
GetTOMLTable(
<TOMLcontents: String> , <table name : String> ) : StringList
//since 4.12.5 [W/L/M]
see also : GetTOMLTable
Boolean operators and functions
see also : Boolean Expressions
<string1> =
<string2> [W/L/M]
<bool1> AND
<bool2> [W/L/M]
<bool1> OR
<bool2> [W/L/M]
NOT
(<bool3>) [W/L/M]
FileExists (
<file name> )
[W/L/M]
see also : FileExists
FileExists32 (
<file name> )
[W]
see also : FileExists
FileExists64 (
<file name> )
[W]
see also : FileExists
FileExistsSysNative (
<file name> )
[W]
see also : FileExists
DirectoryExists (
<folder path> )
//since 4.12.1 [W/L/M]
'sysnative' is the default for <access str>. Otherwise, it can be '32bit', '64bit' or 'sysnative'
see also : DirectoryExists
FileOrFolderExists (
<file or folder path> )
[W/L/M]
'sysnative' is the default for <access str>. Otherwise, it can be '32bit', '64bit' or 'sysnative'
see also : FileOrFolderExists
fileIsSymlink (
<file name> )
// since 4.12.4.21 [W/L/M]
see also : fileIsSymlink
LineExistsIn (
<string>, <file name> )
[W/L/M]
see also : LineExistsIn
LineBeginning_ExistsIn (
<string>, <file name> )
[W/L/M]
see also : LineBeginning_ExistsIn
LineContaining_ExistsIn(
<string>, <file name> )
//since 4.11.4.10: true: if a in <file name> contains <string> [W/L/M]
see also : LineContaining_ExistsIn
XMLAddNamespace(
<XMLfilename>, <XMLelementname>, <XMLnamespace> )
[W]
see also : XMLAddNamespace
XMLRemoveNamespace(
<XMLfilename>, <XMLelementname>, <XMLnamespace> )
[W]
see also : XMLRemoveNamespace
HasMinimumSpace (
<drive letter>, <capacity> )
[W]
see also : HasMinimumSpace
Example:
if not (HasMinimumSpace ("%SYSTEMDRIVE%", "500 MB"))
LogError "Required free space of 500 MB not available on %SYSTEMDRIVE%"
isFatalError
endif
opsiLicenseManagementEnabled
[W/L/M]
see also : opsiLicenseManagementEnabled
runningAsAdmin
//since 4.11.1.1 [W/L/M]
see also : runningAsAdmin
isLoginScript
//since 4.11.2.1 [W]
see also : isLoginScript
contains(
<str>, <substr> )
//since 4.11.3: true if <substr> in <str> [W/L/M]
see also : contains
isNumber(
<str> )
//since 4.11.3: true if <str> represents an integer [W/L/M]
see also : isNumber
runningOnUefi
//since 4.11.4.3: true: if the running OS was booted in UEFI mode [W]
see also : runningOnUefi
runningInPE
//since 4.12.0.13: true: if the running OS is a Windows PE [W/L/M]
see also : runningInPE
runningInWAnMode
//since 4.12.4.16: true: if opsiserver = localhost [W/L/M]
see also : runningInWAnMode
isDriveReady(
<drive letter> )
//since 4.11.4.4: true: if the drive can be accessed [W]
see also : isDriveReady
runningWithGui
//since 4.12.3.6: true: if the running OS has a GUI (at Win+Mac always true)[M/L/W]
see also : runningWithGui
saveTextFile(
<list>, < filename> )
//since 4.11.4.4: true: if list is succesfully written to file [W/L/M]
see also : saveTextFile
saveTextFileWithEncoding(
<list>, < filename>, <encoding> )
//since 4.11.6.4: true: if list is succesfully written to file [W/L/M]
see also : saveTextFileWithEncoding
saveUnicodeTextFile(
<list>, < filename>, <encoding> )
//since 4.12.4.13: true: if list is succesfully written to unicode file [W/L/M]
see also : saveUnicodeTextFile
CompareDotSeparatedNumbers(
<str1>,<relation str>,<str2> )
//since 4.11.5.2: [W/L/M]
see also : CompareDotSeparatedNumbers_bool
CompareDotSeparatedStrings(
<str1>,<relation str>,<str2> )
//since 4.11.5.2: [W/L/M]
see also : CompareDotSeparatedStrings_bool
RegKeyExists(
<regkey>[,<access str>])
//since 4.12.0.16 [W]
<access str> = one of 32bit, 64bit, sysnative ; default sysnative
see also : RegKeyExists
RegVarExists(
<regkey>, <var str>[,<access str>])
//since 4.12.0.16 [W]
<access str> = one of 32bit, 64bit, sysnative ; default sysnative
see also : RegVarExists
isPingReachable(
<host> )
//since 4.12.3.6 [W/L/M]
see also : isPingReachable
isValidFQDN(
<domain name> )
//since 4.12.4.4 [W/L/M]
see also : isValidFQDN
fileHasBom (
<file name> )
//since 4.12.4.17 [W/L/M]
see also : fileHasBom
SaveToTOMLFile(
<TOMLcontents: String> , <TOML file Path: String> )
//since 4.12.5 [W/L/M]
see also : SaveToTOMLFile
ConvertTOMLfileToJSONfile(
<TOMLfilePath: String> , <JSONfilePath: String> )
//since 4.12.5 [W/L/M]
see also : ConvertTOMLfileToJSONfile
Misc functions
Killtask
<process name> [W/L/M]
see also : Killtask
requiredOpsiscriptVersion
<relation operator> <version> //since 4.12.3.6 [W/L/M]
requiredOpsiscriptVersion >= "4.12.3.6"
see also : requiredOpsiscriptVersion
requiredWinstVersion
<relation operator> <version> [W/L/M]
outdatet - use requiredOpsiscriptVersion
see also : requiredOpsiscriptVersion
UpdateEnvironment
//since 4.11.5 [W]:
Subsequent calls of winbatch
with the parameter /RunElevated
will see the changed Environment (NT6 only).
see also : UpdateEnvironment
Flow control
'if - elseif - else - endif' [W/L/M] see also : Syntax und Bedeutung der primären Sektionen eines opsi-script Skripts [W/L/M]]
Syntax:
if
<condition>
;statement(s)
[elseif
<condition>
;statement(s)]
[else
;statement(s)]
endif
elseif
//since 4.12.4.37
Example:
Set $NTVer$ = GetMsVersionInfo
if ( $NTVer$ >= "6" )
sub_install_win7
else
if ( $NTVer$ = "5.1" )
sub_install_winXP
else
stop "not a supported OS-Version"
endif
endif
'for - to - do' Statement //since 4.11.5 [W/L/M] see also : ForToDo
for
%<temporary string variable>% =
<start string> to
<end string> do
<one statement>
Example:
for %s% = "1" to "5" do sub_iteration_test
'Switch / Case' Statement //since 4.11.5 [W/L/M]
ifdef::manual[see also : SwitchCase]
Can not be nested.
see also : IfElseEndif
Syntax:
Switch <string expression> Case <string const> <statement(s)> EndCase [DefaultCase <statement(s)> EndCase] EndSwitch
Example:
set $ConstTest$ = "5"
Switch $ConstTest$
Case "1"
set $CompValue$ = "1"
EndCase
Case "2"
set $CompValue$ = "2"
EndCase
DefaultCase
set $CompValue$ = "notexisting"
EndCase
EndSwitch
isFatalError
[W/L/M]
see also : isFatalError
isFatalError
<string> //since 4.11.3.2 [W/L/M]
see also : isFatalError
isSuccess
//since 4.11.3.7 [W/L/M]
see also : isSuccess
isSuspended
//since 4.11.4.1 [W/L/M]
see also : isSuspended
noUpdateScript
//since 4.11.3.7 [W/L/M]
see also : noUpdateScript
ExitWindows /Reboot
[W/L/M]
see also : Reboot
ExitWindows /ImmediateReboot
[W/L/M]
see also : ImmediateReboot
ExitWindows /ImmediateLogout
[W]
see also : ImmediateLogout
ExitWindows /ShutdownWanted
[W]
see also : ShutdownWanted
ExitWindows /RebootWanted
(deprecated, acts like /Reboot) [W]
see also : Reboot
sleepSeconds
<Integer> or <string> : noresult [W/L/M]
see also : sleepSeconds
ChangeDirectory
<directory> //since 4.11.2.6 [W/L/M]
see also : ChangeDirectory
Secondary Sections
Winbatch [W/L/M]
see also : WinBatch-Sections [W/L/M]
Function: execute programs via operating system API
[WinBatch
<identifier> ]
Modifier:
/LetThemGo
/WaitForProcessEnding
"<program.exe>"
/TimeOutSeconds
<seconds>
/WaitForWindowAppearing
<window title> ('does not work with 64 Bit programs') [W]
/WaitForWindowVanish
<window title> ('does not work with 64 Bit programs') [W]
/RunElevated
// since 4.11.3: only at >= NT6 ; no network access [W]
/RunAsLoggedOnUser
// since 4.11.3.5 ; works only inside 'userLoginScripts' [W]
/32Bit
//since 4.11.3.5 [W]
/64Bit
//since 4.11.3.5 [W]
/SysNative
//since 4.11.3.5 [W]
ShellScript (deprecated: DosBatch, DosInAnIcon, ShellBatch, ShellInAnIcon) //since 4.12.10.0 [W/L/M]
see also : ShellScript section
see also : ShellScript Sections
Function: Execute section via cmd.exe [W] or bash [L/M]
[ShellScript<identifier> ]
<optional parameters> <winst <modifier>>
Modifier: //since 4.11.1.1
/32Bit [W]
/64Bit [W]
/SysNative [W]
/showoutput [W/L/M] // since 4.11.4.7
/WaitForProcessEnding "<program.exe>" // since 4.12.4 [W/L/M]
/TimeOutSeconds <seconds> // since 4.12.4 [W/L/M]
/LetThemGo //since 4.12.10.0
/RunElevated // since 4.12.4: only at >= NT6 ; no network access [W]
/RunAsLoggedOnUser // since 4.12.4.31 ; works only inside 'userLoginScripts' [W]
The modifiers has to be seperated by 'winst' from the parameters.
ShellScript_do_64bit_stuff winst /64Bit
ExecWith [W/L/M]
see also : ExecWith Sections
Function: Execute section via any interpreter
[ExecWith
<identifier> ]
<path to interpreter>
Modifier:
/LetThemGo
/EscapeStrings
/32Bit
//since 4.11.3.5 [W]
/64Bit
//since 4.11.3.5 [W]
/SysNative
//since 4.11.3.5 [W]
The modifiers has to be seperated by 'winst' from the parameters. The following example call the 64Bit version of the powershell.exe.
ExecWith_do_64bit_stuff "%System%\WindowsPowerShell\v1.0\powershell.exe" winst /64Bit
Commands: see manual
Files [W/L/M]
see also : Files
Function: File Operations
[Files
<identifier> ]
Modifier [W]:
/AllNTUserProfiles
/AllNTUserSendTo
[W]
/32Bit
//since 4.10.8 [W]
/64Bit
//since 4.10.8 [W]
/SysNative
//since 4.10.8 [W]
Commands:
checkTargetPath =
<destination directory> [W/L/M]
copy
[Options] <source file(s)> <destination directory> [W/L/M]
some options:
-s
recursive [W/L/M]
-e
empty Subdirectories
-V
version control against targetdir [W]
-v
version control against targetdir, %systemroot% and %system% (do not use it) [W]
-c
continue without reboot even if it is needed [W]
-d
date check [W]
-u
update [W]
-x
extract [W]
-w
weak (do not overwrite protected files) [W]
-n
no overwrite [W]
-r
copy read only attribute [W]
-h
follow symlinks [L] //since 4.11.6.14
delete
[Options] <path[/mask]] // [W/L/M]
options:
-s
recursive
-f
force
r
-del on reboot
c
continue with out reboot
d [n]
date
Example (do not forget the trailing Backslash):
delete -sf c:\delete_this_dir\
del
[Options] <path[/mask]] //since 4.11.2.1 [W/L/M]
Works like delete
but on
del -s -f c:\not-exists
if c:\not-exists not exists it do not search complete c:\ for not-exits
Example (you may forget the trailing Backslash):
del -sf c:\delete_this_dir
chmod
<mode> <path> //since 4.11.4.1 [L]
hardlink
<existing file> <new file> // since 4.11.5 [W/L/M]
symlink
<existing file> <new file> // since 4.11.5 [W/L/M]
At Windows symlink
is only available at NT6 and up.
rename
<old filename> <new filename> // since 4.11.5 [W/L/M]
move
<old filename> <new filename> // since 4.11.5 [W/L/M]
zipfile
<source dir> <zip file> // since 4.12.1 [W/L/M]
unzipfile
<zip file> <target dir> [<encoding>] // since 4.12.1 [W/L/M]
Registry [W]
see also : Registry
Function: edit Registry
Standard method call:
[Registry
<identifier> ]
works with the specified section.
Alternative method call:
Registry loadUnicodeTextFile(
<.reg file> ) /regedit
import the specified <.reg file>.
Alternative method call (deprecated):
Registry loadUnicodeTextFile(
<.addreg file> ) /addreg
import the specified <.addreg file>.
Modifier:
/AllNTUserDats
/32Bit
//since 4.10.8
/64Bit
//since 4.10.8
/SysNative
//since 4.10.8
Commands:
OpenKey
<Key>
openkey [HKLM\Software\opsi.org]
Set
<varname> =
<registry type>:<value>
Add
<varname> =
<registry type>:<value>
Examples for registry types:
set "var1" = "my string"
set "var2" = REG_SZ:"my string"
set "var3" = REG_EXPAND_SZ:"%ProgramFiles%"
set "var4" = REG_DWORD:123 ; Decimal
set "var5" = REG_DWORD:0x7b ; Hexadecimal
; REG_QWORD is supported since 4.12.6
set "var6" = REG_QWORD:59049772908 ; Decimal
set "var7" = REG_QWORD:0xDBFA4076C ; Hexadecimal
set "var8" = REG_BINARY:00 01 02 0F 10
set "var9" = REG_MULTI_SZ:"A|BC|de"
Supp
<varname> <list char> <supplement>
supp "Path" ; "C:\utils; %JAVABIN%"
GetMultiSZFromFile
<varname> <file name>
SaveValueToFile
<varname> <file name>
DeleteVar
<varname>
DeleteKey
<registry key> (does since 4.11.2.1 also work with /AllNTUserDats)
Patches [W/L/M]
see also : Patches
Function: edit Ini-files
[Patches
<identifier> ]
<file name>
Modifier:
/AllNTUserProfiles
//since 4.11.3 [W]
Commands:
add [
<section name> ]
<variable1> =
<value1>
set [
<section name> ]
<variable1> =
<value1>
addnew [
<section name> ]
<variable1> =
<value1>
change [
<section name> ]
<variable1> =
<value1>
del [
<section name> ]
<variable1> =
<value1>
del [
<section name> ]
<variable1>
delsec [
<section name> ]
replace
<variable1> =
<value1> <variable2> =
<value2>
PatchTextFile [W/L/M]
see also : PatchTextFile
Function: edit text files
[PatchTextFile
<identifier> ]
<file name>
Modifier:
/AllNTUserProfiles
//since 4.11.3.4 [W]
/encoding
<encoding> //since 4.12.4.17 [W/L/M]
Commands:
Set_Mozilla_Pref (
<preference type>, <preference key>, <preference value> )
'preference type' takes any value.
Some examples for preference types: pref
, user_pref
, lock_pref
or lockPref
.
AddStringListElement_To_Mozilla_Pref (
<preference type>, <preference key>, <add value> )
Set_Netscape_User_Pref (
<key>, <value> )
('deprecated')
AddstringListElement_To_Netscape_User_Pref
('deprecated')
FindLine
<search string>
FindLine_StartingWith
<search string>
FindLine_Containing
<search string>
GoToTop
AdvanceLine
[<number of lines>]
GoToBottom
DeleteTheLine
AddLine_
<line> or Add_Line_
<line>
InsertLine
<line> or Insert_Line_
<line>
AppendLine
<line> or Append_Line
<line>
Append_File
<file name>
Subtract_File
<file name>
SaveToFile
<file name>
Sorted
setKeyValueSeparator
<separator char> //since 4.11.4.4 [W/L/M]
setValueByKey
<keystr> <valuestr> //since 4.11.4.4 [W/L/M]
searchAndReplace
<searchstr> <replacestr> //since 4.11.4.6 [W/L/M]
LinkFolder [W/L/M]
see also : LinkFolder
Function: Startmenue + Desktop Icons
[LinkFolder
<identifier> ]
Commands:
set_basefolder
<system folder>
set_subfolder
<folder path> (at Linux set always "")
set_link name: <link name> target: <path and name of the program> parameters: [command line arguments] working_dir: [working directory] icon_file: [path and name of icon file, default=target] icon_index: [number of icon in icon file, default=0] [W] shortcut: [keyboard shortcut for calling the target] [W] link_categories: [list of categories] [L] end_link
delete_element
<link name>
delete_subfolder
<folder path> [W]
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
Predefined link_categories
for Linux:
AudioVideo
, Audio
, Video
, Development
, Education
, Game
, Graphics
, Network
, Office
, Settings
, System
, Utility
Examples
set_basefolder common_desktopdirectory
set_subfolder ""
set_link
name: opsi-winst
target: "%ProgramFiles32Dir%\opsi.org\opsi-client-agent\opsi-winst\winst32.exe"
end_link
[LinkFolder_configed_lin]
set_basefolder common_programs
set_subfolder ""
set_link
name: opsi-configed-Local
target: java
parameters: $parameter$
icon_file: "$InstallDir$/opsi.png"
link_categories: System;Utility;
end_link
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.7
shortcut
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.
OpsiServiceCall [W/L/M]
see also : OpsiServiceCall
Function: opsi-Service access
[OpsiServiceCall
<identifier> ]
Commands: see manual
PatchHosts [W/L/M]
see also : PatchHosts
Function: hosts-files bearbeiten
[PatchHosts
<identifier> ]
Commands:
setaddr
<hostname> <IPaddress>
setname
<IPaddress> <hostname>
setalias
<hostname> <alias>
setalias
<IPadresse> <alias>
delalias
<hostname> <alias>
delalias
<IPaddress> <alias>
delhost
<hostname>
delhost
<ipadresse>
setComment
<ident> <comment>
XML2 Sections [W/L/M]
see also : XML2 Sections
Function: edit XML files
since 4.12.1.0
[XML2
<identifier> ]
Commands:
-
strictMode =
(true/false) ; Default: false -
openNode
<xml2 path>
Open the given path as actual node. If the path does not exist, it will be created. -
SetAttribute
<attr name> <attr value>
At the actual node set <attr value> as value of <attr name>. If <attr name> does not exist, it will be created. -
AddAttribute
<attr name> <attr value>
If the attribute <attr name> does not exist at the actual node, it will be created with <attr value> as value. If <attr name> already exists, nothing will be changed. -
DeleteAttribute
<attr name>
If the attribute <attr name> exists at the actual node, it will be deleted. -
addNewNode
<node name>
Create at the actual node a new sub node <node name> and make this new node to the actual node. -
setNodeText
<string> -
DeleteNode
<xml2 path> -
gotoParentNode
Make the parent node to the actual node. -
rootNodeOnCreate
= <node name> // since 4.12.4.27
If the file does not exist, it will be created with <node name> as root node name. -
setNodePair
<keyNodeName> <keyNodeTextContent> <valueNodeName> <valueNodeTextContent> // since 4.12.4.28
Creates a <dict> entry like it is used in the Apple info.plist files.
Some notes on the command parameters:
-
<xml2 path>
strictMode =false
:
A line of xml node names without any attributes seprated by//
.
Example:node_level-1_number-1 // node_level-2_B color="green"
-
<xml2 path>
strictMode =true
:
A line of xml node names with all existing attributes seprated by//
.
Example:node_level-1_number-1 // node_level-2_B color="green" count="65"
see also : XML related functions (XML2) [W/L/M]:
see also : XML2 Functions
XMLPatch [W]
see also : XMLPatch
Function: edit XML files
Deprecated: please use xml2 sections: XML2 Sections [W/L/M]
and xml2 functions: XML related functions (XML2) [W/L/M]:
[XMLPatch
<identifier> ]
Commands: see manual
ExecPython [W/L/M]
see also : ExecPython
Function: Execute section via python interpreter
[ExecPython
<identifier> ]
Commands: see manual
LdapSearch [WLM]
see also : LdapSearch
Function: read from LDAP
[LdapSearch
<identifier> ]
Commands: see manual
By Topic
Compare related functions [W/L/M]
CompareDotSeparatedStrings(
<string1>, <string2> ) : string
[W/L/M]
see also : CompareDotSeparatedStrings_str
CompareDotSeparatedStrings(
<str1>,<relation str>,<str2> ) : bool
//since 4.11.5.2: [W/L/M]
see also : CompareDotSeparatedStrings_bool
CompareDotSeparatedNumbers(
<string1>, <string2> ) : string
[W/L/M]
see also : CompareDotSeparatedNumbers_str
CompareDotSeparatedNumbers(
<str1>,<relation str>,<str2> ) : bool
//since 4.11.5.2: [W/L/M]
see also : CompareDotSeparatedNumbers_bool
boolToString(
<boolean expression> )
: bool string (true/false) // since 4.12.0.0 [W/L/M]
see also : boolToString
stringToBool(
<string expression: true/false> )
: boolean // since 4.12.0.0 [W/L/M]
see also : stringToBool
Crypt / Hash related functions [W/L/M]
DecStrToHexStr (
<decstring>, <hexlength> ) : string
[W/L/M]
see also : DecStrToHexStr
HexStrToDecStr (
<hexstring> ) : string
[W/L/M]
see also : HexStrToDecStr
base64EncodeStr(
<string> ) : string
[W/L/M]
see also : base64EncodeStr
base64DecodeStr(
<string> ) : string
[W/L/M]
see also : base64DecodeStr
RandomStr : string
[W/L/M]
see also : RandomStr
RandomIntStr(
<number str> ) : string
[W/L/M]
see also : RandomIntStr
encryptStringBlow(
<keystring>,<datastring> ) : string
[W/L/M]
see also : encryptStringBlow
decryptStringBlow(
<keystring>,<datastring> ) : string
[W/L/M]
see also : decryptStringBlow
md5sumFromFile(
<path to file> ) : string
[W/L/M]
see also : md5sumFromFile
hashFromFile(
<FileName>, <Hashing Algorithm> ) : string
[W/L/M] //since 4.12.5
see also : hashFromFile
isCertInstalledInSystem(
<label> ) : boolstring
[W/L/M] //since 4.12.4.37
see also : isCertInstalledInSystem
importCertToSystem(
<filename> ) : noresult
[W/L/M] //since 4.12.4.37
see also : importCertToSystem
removeCertFromSystem(
<label> ) : noresult
[W/L/M] //since 4.12.4.37
see also : removeCertFromSystem
listCertificatesFromSystem : stringlist
[W/L/M] //since 4.12.4.37
see also : listCertificatesFromSystem
Defined Functions and Libraries [W/L/M]
since 4.12.0.0
Definition
DefFunc <func name>([calltype parameter ptype][,[calltype parameter ptype]]) : ftype <function body> endfunc
Where:
-
DefFunc
is the keyword used to start defining a local function. -
'<func name>' is the freely choosen name of 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 freely 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 and either
string
orstringlist
. -
'ftype' is the type of data of the function and either
string
,stringlist
orvoid
.void
declares that no result is returned. -
'<function body>' is the body of the function which must conform to the opsi-script syntax.
-
endfunc
is the keyword used to end defining a local function.
see also : localfunctions
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/M]
-
An existing file in
%ScriptPath%
[W/L/M] -
A file in
%opsiScriptHelperPath%\lib
[W]
Is equivalent to: '%ProgramFiles32Dir%\opsi.org\opsiScriptHelper\lib' -
An existing file in
%ScriptPath%/../lib
[W/L/M] -
An 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.
see also : Import of libraries of functions
Encoding related functions [W/L/M]
encoding=
<encoding> // (default is system encoding) since 4.11.4.2
see also : encoding
GetLocaleInfoMap : stringlist
[W]
see also : GetLocaleInfoMap
reencodestr(
<str>, <from>, <to> ) : string
//since 4.11.4.2 [W/L/M]
see also : reencodestr
reencodestrlist(
<list>, <from>, <to> ) : stringlist
//since 4.11.4.2 [W/L/M]
see also : reencodestrlist
fileHasBom (
<file name> ) : boolean
//since 4.12.4.17 [W/L/M]
see also : fileHasBom
loadUnicodeTextFile (
<file name> ) : stringlist
[W/L/M]
see also : loadUnicodeTextFile
loadTextFileWithEncoding(
<file name> ,
<encoding> ) : stringlist
//since 4.11.5 [W/L/M]
see also : loadTextFileWithEncoding
strLoadTextFileWithEncoding (
<filename> , <encoding> ) : string
//since 4.11.4.6 [W/L/M]
see also : strLoadTextFileWithEncoding
saveTextFileWithEncoding(
<list>, < filename> ,
<encoding> ) : bool
//since 4.11.6.4: true: if list is succesfully written to file [W/L/M]
see also : saveTextFileWithEncoding
includelog
<file name> <tail size> [<encoding>] : noresult
//since 4.11.4.1 [W/L/M]
see also : includelog
see also : 'opsi-script' encoding
Error / Warning related functions [W/L/M]
ExitOnError
= <boolean value> // (default=false)
see also : ExitOnError
ScriptErrorMessages
= <boolean value> // (default=true)
see also : ScriptErrorMessages
see also : Central configuration via opsi Configs
FatalOnSyntaxError =
<boolean value> // (default=true) since 4.11.3.2
see also : FatalOnSyntaxError
FatalOnRuntimeError =
<boolean value> // (default=false) since 4.11.3.2
see also : FatalOnRuntimeError
LogError
<string> or LogError
= <const string>
see also : LogError
LogWarning
<string> or LogWarning
= <const string>
see also : LogWarning
isFatalError
[W/L/M]
see also : isFatalError
isFatalError
<string> //since 4.11.3.2 [W/L/M]
see also : isFatalError
markErrorNumber
see also : markErrorNumber
errorsOccurredSinceMark
<relation> <integer> : boolean
see also : errorsOccurredSinceMark
markErrorNumber
comment "log error and thereby increase the error counter"
if errorsOccurredSinceMark > 0
comment "There was an error ..."
endif
getLastExitCode : string (exitcode)
[W/L/M]
see also : getLastExitCode
shellCall (
<command string> ) : string (exitcode)
//since 4.11.6.1 [W/L/M]
see also : shellCall_str
processCall(
<string> ) : string (exitcode)
//since 4.11.6.1 [W/L/M]
see also : processCall
getLastServiceErrorClass
: string
see also : getLastServiceErrorClass
getLastServiceErrorMessage
: string
see also : getLastServiceErrorMessage
File related functions [W/L/M]
strLoadTextFile (
<file name> ) : string
[W/L/M]
see also : strLoadTextFile
strLoadTextFileWithEncoding (
<filename> , <encoding> ) : string
//since 4.11.4.6 [W/L/M]
see also : strLoadTextFileWithEncoding
loadTextFile (
<file name> ) : stringlist
[W/L/M]
see also : loadTextFile
loadUnicodeTextFile (
<file name> ) : stringlist
[W]
see also : loadUnicodeTextFile
loadTextFileWithEncoding(
<file name> ,
<encoding> ) : stringlist
//since 4.11.5 [W/L/M]
see also : loadTextFileWithEncoding
fileHasBom (
<file name> ) : boolean
//since 4.12.4.17 [W/L/M]
see also : fileHasBom
FileExists (
<file name> ) : bool
[W/L/M]
see also : FileExists
FileExists32 (
<file name> ) : bool
[W]
see also : FileExists
FileExists64 (
<file name> ) : bool
[W]
see also : FileExists
FileExistsSysNative (
<file name> ) : bool
[W]
see also : FileExists
DirectoryExists
(<folder path> [,<access str>]) : boolean //since 4.12.1 [W/L/M]
'sysnative' is the default for <access str>. Otherwise, it can be '32bit', '64bit' or 'sysnative'
see also : DirectoryExists
FileOrFolderExists
(<file or folder path> [,<access str>]) : boolean [W/L/M]
'sysnative' is the default for <access str>. Otherwise, it can be '32bit', '64bit' or 'sysnative'
see also : FileOrFolderExists
fileIsSymlink (
<file name> ) : bool
// since 4.12.4.21 [W/L/M]
see also : fileIsSymlink
resolveSymlink (
<file name> ) : string
// since 4.12.4.21 [W/L/M]
see also : resolveSymlink
listFiles (
<Path>, <Searchmask> , <SearchSubDirectories>, <[Redirection]> ) : stringlist
//since 4.12.3 [W/L/M]
Set $Filelist$ = listFiles("C:\windows\system32","*.ico;*.dll","False","64bit")
see also : listFiles
forcePathDelims (
<path string> ) : string
// since 4.12.4.21 [W/L/M]
see also : forcePathDelims
LineExistsIn (
<string>, <file name> ) : bool
[W/L/M]
see also : LineExistsIn
LineBeginning_ExistsIn (
<string>, <file name> ) : bool
[W/L/M]
see also : LineBeginning_ExistsIn
LineContaining_ExistsIn(
<string>, <file name> ) : bool
//since 4.11.4.10 [W/L/M]
true: if a in <file name> contains <string>
see also : LineContaining_ExistsIn
saveTextFile(
<list>, < filename> ) : bool
//since 4.11.4.4 [W/L/M]
true: if list is succesfully written to file
see also : saveTextFile
saveTextFileWithEncoding(
<list>, < filename> ,
<encoding> ) : bool
//since 4.11.6.4 [W/L/M]
true: if list is succesfully written to file
see also : saveTextFileWithEncoding
getFileInfoMap(
<file name> ) : stringlist
[W]
see also : getFileInfoMap
getFileInfoMap32(
<file name> ) : stringlist
//since 4.11.6.6 [W]
see also : getFileInfoMap
getFileInfoMap64(
<file name> ) : stringlist
//since 4.11.6.6 [W]
see also : getFileInfoMap
getFileInfoMapSysnative(
<file name> ) : stringlist
//since 4.11.6.6 [W]
see also : getFileInfoMap
ExtractFilePath (
<path> ) : string
[W/L/M]
see also : ExtractFilePath
ExtractFileExtension (
<path> ) : string
[W/L/M] //since 4.12.1
see also : ExtractFileExtension
ExtractFileName (
<path> ) : string
[W/L/M] //since 4.12.1
see also : ExtractFileName
see also: Files [W/L/M]
see also: PatchTextFile [W/L/M]
Ini file related functions [W/L/M]
GetValueFromInifile (
<file path>, <section>, <key>, <default value>, OPTIONAL <encoding> ) : string
[W/L/M]
see also : GetValueFromInifile
getSectionNames(
<ini-file> ) : stringlist
[W/L/M]
see also : getSectionNames
GetSectionFromInifile(
<ini-file> ) : stringlist
[W/L/M]
see also : GetSectionFromInifile
getValue(
<key string>, <hash string list> ) : string
[W/L/M]
see also : getValue
getValueBySeparator(
<key string>,<separator string>,<hash string list> ) : string
//since 4.11.2.1 [W/L/M]
see also : getValueBySeparator
setValueByKey(
<key>, <value>, <targetlist> )
: stringlist [W/L/M]
see also : prim-section.adoc#setValueByKey
getValueFromFile(
<key string>, <file name> ) : string
//since 4.11.4.4 [W/L/M]
see also : getValueFromFile
getValueFromFileBySeparator(
<key string>,<separator string>,<file name> ) : string
//since 4.11.4.4 [W/L/M]
see also : getValueFromFileBySeparator
see also: Patches [W/L/M]
Interaction [W/L/M]
Pause
<string> or Pause
= <const string>
see also : Pause
Stop
<string> or stop
= <const string>
see also : Stop
setActionProgress
<string> //since 4.11.3 [W/L/M]
see also : setActionProgress
Message
<string> or Message
= <const string>
see also : Message
ShowMessageFile
<string>
see also : ShowMessageFile
ShowBitMap
[<file name>] [<sub title>]
see also : ShowBitMap
stringinput(
< message str>,< boolstr confidential> ) : string
//since 4.12.1.2 [W/L/M]
see also : stringinput
editmap(
< strlist> ) : stringlist
//since 4.12.1.2 [W/L/M]
see also : editmap
License Management related functions [W/L/M]
DemandLicenseKey(
poolId [, productId [,windowsSoftwareId]] ) : string
set $mykey$ = DemandLicenseKey ("", "office2007")
see also : DemandLicenseKey
FreeLicense (
poolId [, productId [,windowsSoftwareId]]) : string
set $result$ = FreeLicense("", "office2007")
see also : FreeLicense
getLastServiceErrorClass
: string
see also : getLastServiceErrorClass
getLastServiceErrorMessage
: string
see also : getLastServiceErrorMessage
opsiLicenseManagementEnabled
: bool
see also : opsiLicenseManagementEnabled
Linux specific functions [W/L/M]
GetOS : string
// 'Linux' or 'Windows_NT' or 'macos' [W/L/M]
see also : GetOS
getLinuxDistroType : string
// 'debian' or 'redhat' or 'suse' (see getLinuxVersionMap
) [L]
see also : getLinuxDistroType
getLinuxVersionMap : stringlist
//since 4.11.4 [L]
see also : getLinuxVersionMap
chmod
in Files sections [L/M]
see also : Commands
waitForPackageLock(
<wait_seconds>,<abort_on_timeout> ) : bool
// since 4.11.6.1 [L]
see also : waitForPackageLock
importlib "uib_lin_install"
:
cleanupPackageSystem : void
//since 4.13.4 [L]
see also : cleanupPackageSystem
installupdates : string
//since 4.13.4 [L]
see also : installupdates
debinstall($packagelist$ : stringlist) : string
//since 4.13.4 [L]
see also : debinstall
redinstall($packagelist$ : stringlist) : string
//since 4.13.4 [L]
see also : redinstall
suseinstall($packagelist$ : stringlist) : string
//since 4.13.4 [L]
see also : suseinstall
ucsinstall($packagelist$ : stringlist) : string
//since 4.13.4 [L]
see also : ucsinstall
genericLinInstall($packagelist$ : stringlist) : string
see also : genericLinInstall
linuxInstallOneOf($packagelist$ : stringlist) : string
see also : genericLinInstall
isOneInstalled($packagelist$ : stringlist) : string
see also : linuxInstallOneOf
linuxInstallOneFile($packagefile$ : string) : string
see also : linuxInstallOneFile
linuxRemoveOnePackage($packagename$ : string) : string
see also : linuxRemoveOnePackage
linuxRemoveOneOf($packagelist$ : stringlist) : string
see also : linuxRemoveOneOf
Logging related functions [W/L/M]
SetLogLevel
= <number> or SetLogLevel
= <string> // (default=6)
SetLogLevel = 7
SetLogLevel = "7"
see also : SetLogLevel see also : cli-params.adoc#opsi-script-configs_default_loglevel see also : cli-params.adoc#opsi-script-configs_force_min_loglevel
Message
<string> or Message
= <const string>
see also : Message
comment
<string> or comment
= <const string>
see also : comment
LogError
<string> or LogError
= <const string>
see also : scriptWasExecutedBefore
LogWarning
<string> or LogWarning
= <const string>
see also : LogError
includelog
<file name> <tail size> //since 4.11.2.1 [W/L/M]
see also : includelog
includelog
<file name> <tail size> [<encoding>] //since 4.11.4.1 [W/L/M]
see also : includelog
includelog "%Scriptpath%\test-files\10lines.txt" "5"
SetConfidential
<secret string> //since 4.11.3.5 [W/L/M]
see also : setConfidential
asConfidential(
<secret string expression> ) : string
//since 4.12.0.16 [W/L/M]
see also : asConfidential_str
asConfidential(
<secret stringlist expression> ) : stringlist
//since 4.12.4.15 [W/L/M]
see also : asConfidential_list
forceLogInAppendMode =
<boolean value> // (default=false); if true, log will be send in append mode . //since 4.12.3.6
see also : forceLogInAppendMode
opsi-configs
see also : Central configuration via opsi Configs
opsi-script.global.debug_prog
: boolean ; if false: only Warnings and Errors from program logging; default: false
see also : Central configuration via opsi Configs
opsi-script.global.debug_lib
: boolean ; if false: only Warnings and Errors from library logging; default: false
see also : Central configuration via opsi Configs
opsi-script.global.default_loglevel
: intstr ; set the default log level; default: '6'
see also : Central configuration via opsi Configs
opsi-script.global.force_min_loglevel
: intstr ; set the minimal loglevel; default: '0'
see also : Central configuration via opsi Configs
opsi-script.global.ScriptErrorMessages
: boolean ; overwrites the opsi-script internal default; default: false
see also : ScriptErrorMessages
opsi-script.global.AutoActivityDisplay
: boolean ; overwrites the opsi-script internal default; default: true
see also : AutoActivityDisplay
opsi-script.global.SupressSystemEncodingWarning
: boolean ; suppress some encoding warnings; default: false
see also : SupressSystemEncodingWarning
opsi-script.global.ReverseProductOrderByUninstall
: boolean ; product list is reordered for uninstall; default: false
see also : ReverseProductOrderByUninstall
opsi-script.global.log_rotation_count
: boolean ; number of opsi-script.log backups; default: 8
see also : log_rotation_count
opsi-script.global.writeProductLogFile
: boolean ; logs for every single opsi product; default: false
see also : writeProductLogFile
macOS specific functions [W/L/M]
GetOS : string
// 'Linux' or 'Windows_NT' or 'macos' [W/L/M]
see also : GetOS
getMacosVersionInfo : string
//macOS Version Information //since 4.12.1.0 [M]
see also : getMacosVersionInfo
getMacosVersionMap : stringlist
//macOS Version map //since 4.12.1.0 [M]
see also : getMacosVersionMap
GetSystemType : string
//OS Architecture ("64 Bit System" or "x86 System") [W/L/M]
see also : GetSystemType
getOSArchitecture
// OS Architecture (x86_32 / x86_64/ arm_64) //since 4.12.4.17 [W/L/M]
see also : getOSArchitecture
importlib "uib_macosinstalllib"
:
install_macos_app($myapp$ : string) : string
[M]
see also : xref:libraries.adoc#install_macos_app>>
install_macos_pkg($mypkg$ : string) : string
[M]
see also : xref:libraries.adoc#install_macos_pkg>>
install_macos_dmg($mydmg$ : string) : string
[M]
see also : xref:libraries.adoc#install_macos_dmg>>
install_macos_zip($myzip$ : string) : string
[M]
see also : xref:libraries.adoc#install_macos_zip>>
install_macos_generic($myfile$ : string) : string
[M]
see also : install_macos_generic
Network related functions [W/L/M]
GetHostsName (
<hostaddress> ) : string
[W/L/M]
see also : GetHostsName
GetHostsAddr (
<hostname> ) : string
[W/L/M]
see also : GetHostsAddr
GetMyIpByTarget(
<target ip addr> ) : string
//since 4.11.3.2 /4.11.6 [W/L/M]
see also : GetMyIpByTarget
GetIpByName(
<ip addr / ip name> ) : string
//since 4.11.3.2 [W/L/M]
see also : GetIpByName
isValidIP4 (<ip4adr>) : boolean
//since 4.12.1
see also : isValidIP4
isValidIP4Network (<ip4adr>, <netmask>) : boolean
//since 4.12.1
see also : isValidIP4Network
isValidIP4Host (<ip4adr>, <netmask>) : boolean
//since 4.12.1
see also : isValidIP4Host
getIP4NetworkByAdrAndMask (<ip4adr>, <netmask>) : string
//since 4.12.1
see also : getIP4NetworkByAdrAndMask
getDefaultNetmaskByIP4adr (<ip4adr>) : string
//since 4.12.1
see also : getDefaultNetmaskByIP4adr
parseUrl(<url string>) : stringlist
//since 4.12.1
see also : parseUrl
createUrl(<urlcomponents list>) : string
//since 4.12.1
see also : createUrl
isPingReachable(<host>) : boolean
//since 4.12.3.6
see also : isPingReachable
isValidFQDN(<domain name>) : boolean
//since 4.12.4.4 [W/L/M]
see also : isValidFQDN
cidrToNetmask (<string>) : string
//since 4.12.4.37
see also : prim-section.adoc#cidrToNetmask
netmaskToCidr (<string>) : string
//since 4.12.4.37
see also : prim-section.adoc#netmaskToCidr
isCertInstalledInSystem(
<label> ) : boolstring
[W/L/M] //since 4.12.4.37
see also : prim-section.adoc#sCertInstalledInSystem
importCertToSystem(
<filename> ) : noresult
[W/L/M] //since 4.12.4.37
see also : prim-section.adoc#importCertToSystem
removeCertFromSystem(
<label> ) : noresult
[W/L/M] //since 4.12.4.37
see also : prim-section.adoc#removeCertFromSystem
listCertificatesFromSystem(
<label> ) : stringlist
[W/L/M] //since 4.12.4.37
see also : prim-section.adoc#listCertificatesFromSystem
Number related functions [W/L/M]
isNumber(
<str> ) : bool
//since 4.11.3: true if <str> represents an integer [W/L/M]
see also : isNumber
CompareDotSeparatedNumbers(
<str1>,<relation str>,<str2> ) : bool
//since 4.11.5.2: [W/L/M]
see also : CompareDotSeparatedNumbers_bool
CompareDotSeparatedNumbers(
<string1>, <string2> ) : string
[W/L/M]
see also : CompareDotSeparatedNumbers_str
calculate(
<arithmetic string expression> ) : string (number)
// since 4.11.3.5 [W/L/M]
knows: +-*/()
see also : calculate
DecStrToHexStr (
<decstring>, <hexlength> ) : string
[W/L/M]
see also : DecStrToHexStr
HexStrToDecStr (
<hexstring> ) : string
[W/L/M]
see also : HexStrToDecStr
RandomIntStr(
<number str> ) : string
[W/L/M]
see also : RandomIntStr
Operating System related functions [W/L/M]
GetOS : string
// 'Linux' or 'Windows_NT' or 'macos' [W/L/M]
see also : GetOS
GetMsVersionInfo : string
//Windows Version Information [W]
see also : GetMsVersionInfo
GetMSVersionMap : stringlist
[W]
see also : GetMSVersionMap
getLinuxDistroType : string
// 'debian' or 'redhat' or 'suse' (see getLinuxVersionMap
) [L]
see also : getLinuxDistroType
getLinuxVersionMap : stringlist
//since 4.11.4 [L]
see also : getLinuxVersionMap
getMacosVersionInfo : string
//macOS Version Information //since 4.12.1.0 [M]
see also : getMacosVersionInfo
getMacosVersionMap : stringlist
//macOS Version map //since 4.12.1.0 [M]
see also : getMacosVersionMap
GetSystemType : string
//OS Architecture ("64 Bit System" or "x86 System") [W/L/M]
see also : GetSystemType
getOSArchitecture
// OS Architecture (x86_32 / x86_64/ arm_64) //since 4.12.4.17 [W/L/M]
see also : getOSArchitecture
getListFromWMI(
<wmi namespace str>,<wmi class str>,<property list>,<condition str> ) : stringlist
//since 4.12.1.0 [W]
see also : getListFromWMI
EnvVar (
<environment variable> ) : string
[W/L/M]
see also : EnvVar
getProfilesDirList : stringlist
//since 4.11.3.2 [W/L/M]
see also : getProfilesDirList
listFiles (
<Path>, <Searchmask> , <SearchSubDirectories>, <[Redirection]> ) : stringlist
//since 4.12.3 [W/L/M]
Set $Filelist$ = listFiles("C:\windows\system32","*.ico;*.dll","False","64bit")
see also : listFiles
which(
<command in path> ) : string
(command with path) //since 4.12.3.6 [W/L/M]
see also : which
runningAsAdmin : bool
//since 4.11.1.1 [W/L/M]
see also : runningAsAdmin
runningOnUefi : bool
//since 4.11.4.3: true: if the running OS was booted in UEFI mode [W/L/M]
see also : runningOnUefi
runningInPE : bool
//since 4.12.0.13: true: if the running OS is a Windows PE [W]
see also : runningInPE
runningInWAnMode
//since 4.12.4.16: true: if opsiserver = localhost [W/L/M]
see also : runningInWAnMode
isDriveReady(
<drive letter> ) : bool
//since 4.11.4.4: true: if the drive can be accessed [W]
see also : isDriveReady
runningWithGui : bool
//since 4.12.3.6: true: if the running OS with GUI (at Win+Mac always true)[M/L/W]
see also : runningWithGui
opsiservicecall and json Related functions [W/L/M]
jsonIsValid(
<jsonstr> ) : boolean
//since 4.11.6: [W/L/M]
see also : jsonIsValid
jsonIsArray(
<jsonstr> ) : boolean
//since 4.11.6: [W/L/M]
see also : jsonIsArray
jsonIsObject(
<jsonstr> ) : boolean
//since 4.11.6: [W/L/M]
see also : jsonIsObject
jsonAsObjectHasKey(
<jsonstr>,<keystr> ) : boolean
//since 4.11.6: [W/L/M]
see also : jsonAsObjectHasKey
jsonAsArrayCountElements(
<jsonstr> ) : intstr
//since 4.11.6: [W/L/M]
see also : jsonAsArrayCountElements
jsonAsObjectCountElements(
<jsonstr> ) : intstr
//since 4.11.6: [W/L/M]
see also : jsonAsObjectCountElements
jsonAsArrayGetElementByIndex(
<jsonstr>, <indexstr> ) : jsonstring
//since 4.11.6: [W/L/M]
see also : jsonAsArrayGetElementByIndex
jsonAsObjectGetValueByKey(
<jsonstr>, <keystr> ) : valuestring
//since 4.11.6: [W/L/M]
see also : jsonAsObjectGetValueByKey
jsonAsObjectSetValueByKey(
<jsonstr>, <keystr>,<valuestring> ) : jsonstring
//since 4.11.6: [W/L/M]
see also : jsonAsObjectSetValueByKey
jsonAsObjectSetStringtypeValueByKey(
<jsonstr>, <keystr>,<valuestring> ) : jsonstring
//since 4.11.6: [W/L/M]
see also : jsonAsObjectSetStringtypeValueByKey
jsonAsObjectDeleteByKey(
<jsonstr>, <keystr> ) : jsonstring
//since 4.11.6.4: [W/L/M]
see also : jsonAsObjectDeleteByKey
jsonAsArrayPutObjectByIndex(
<jsonstr>, <indexstr>, <objectstr> ) : jsonstring
//since 4.11.6: [W/L/M]
see also : jsonAsArrayPutObjectByIndex
jsonAsArrayDeleteObjectByIndex(
<jsonstr>, <indexstr> ) : jsonstring
//since 4.11.6.4: [W/L/M]
see also : jsonAsArrayDeleteObjectByIndex
jsonAsArrayToStringList(
<jsonstr> ) : stringlist
//since 4.11.6: [W/L/M]
see also : jsonAsArrayToStringList
jsonAsObjectGetKeyList(
<jsonstr> ) : stringlist
//since 4.11.6: [W/L/M]
see also : jsonIsArray
jsonStringListToJsonArray(
<strlist> ) : jsonstr
//since 4.11.6: [W/L/M]
see also : jsonAsObjectGetKeyList
convert2Jsonstr(
<string> )
//since 4.10.8.3
see also: OpsiServiceCall OpsiServiceCall [W/L/M]
see also : OpsiServiceCall and json Related functions
see also : OpsiServiceCall Sections
opsi related functions [W/L/M]
getProductMap : stringlist
// since 4.11.2.4 [W/L/M]
keys are: id, name, description, advice, productversion, packageversion, priority, installationstate, lastactionrequest, lastactionresult, installedversion, installedpackage, installedmodificationtime,actionrequest
see also : getProductMap
getProductPropertyList(
<propname>,<default value> ) : stringlist
//since 4.11.3 [W/L/M]
see also : getProductPropertyList
GetProductProperty (
<PropertyName>, <DefaultValue> ) : string
[W/L/M]
see also : GetProductProperty
GetConfidentialProductProperty (
<PropertyName>, <DefaultValue> ) : string
//since 4.11.5.2 [W/L/M]
see also : GetConfidentialProductProperty
setActionProgress
<string> //since 4.11.3 [W/L/M]
see also : setActionProgress
retrieveSection (
<section name> ) : stringlist
[W/L/M]
see also : retrieveSection
replaceOpsiConstants(
<string list> ) : stringlist
//since 4.12.3.6 [W/L/M]
see also : replaceOpsiConstants_list
replaceOpsiConstants(
<string> ) : string
//since 4.12.3.6 [W/L/M]
see also : replaceOpsiConstants_string
runningInWanMode
: boolean //since 4.12.4.17 [W/L/M]
see also : runningInWanMode
reloadProductList
//since 4.12.6.1 [W/L/M]
see also : reloadProductList
Process and Script Related functions
Killtask
<process name> : noresult
[W/L/M]
see also : Killtask
ChangeDirectory
<directory> : noresult //since 4.11.2.6 [W/L/M]
see also : ChangeDirectory
GetProcessList : stringlist
//since 4.11.1.2; gives list of exename;pid;dom/user [W/L/M]
see also : GetProcessList
processIsRunning(
<process name> ) : boolean
//since 4.11.6.1 [W/L/M]
see also : processIsRunning
isProcessChildOf(<searchprocstr>, <parentprocstr>): bool
//since 4.12.4.35 [W/L/M]
see also : prim-section.adoc#isProcessChildOf
shellCall (
<command string> ) : stringlist (output)
//since 4.11.4.2 [W/L/M]
see also : shellCall_list
set $list$= shellCall('net start')
shellCall (
<command string> ) : noresult
//since 4.11.6.1 [W/L/M]
see also : shellCall
shellCall (
<command string> ) : string (exitcode)
//since 4.11.6.1 [W/L/M]
see also : shellCall_str
powershellcall (
<commandstr> [,<access str>='sysnative' [,<policy bool str>='true']]) : stringlist (output)
//since 4.12.0.16 [W]
powershellCall(
<commandstr> [,<access str>='sysnative' [,<policy bool str>='true'][, <optionstr> = '']]) : stringlist (output)
//since 4.12.4.28 [W]
see also : powershellCall_list
powershellcall (
<commandstr> [,<access str>='sysnative' [,<policy bool str>='true']]) : noresult
//since 4.12.0.16 [W]
powershellCall(
<commandstr> [,<access str>='sysnative' [,<policy bool str>='true'][, <optionstr> = '']]) : noresult
//since 4.12.4.28 [W]
see also : powershellCall
powershellcall (
<commandstr> [,<access str>='sysnative' [,<policy bool str>='true']]) : string (exitcode)
//since 4.12.0.16 [W]
powershellCall(
<commandstr> [,<access str>='sysnative' [,<policy bool str>='true'][, <optionstr> = '']]) : string (exitcode)
//since 4.12.4.28 [W]
see also : powershellCall_str
getOutStreamFromSection (
<dos section name> ) : stringlist (output)
[W/L/M]
set $list$= getOutStreamFromSection ('ShellScript_try')
see also : getOutStreamFromSection see also : opsi-script-ShellScript-catchout
processCall(
<string> ) : string (exitcode)
//since 4.11.6.1 [W/L/M]
see also : processCall
getLastExitCode : string (exitcode)
[W/L/M]
see also : getLastExitCode
includelog
<file name> <tail size> : noresult
//since 4.11.2.1 [W/L/M]
see also : includelog
includelog
<file name> <tail size> [<encoding>] : noresult
//since 4.11.4.1 [W/L/M]
see also : includelog
waitForPackageLock(
<seconds timeout string>,<bool should we kill> ) : bool
//since 4.11.6.1 [L]
see also : waitForPackageLock
which(
<command in path> ) : string
(command with path) //since 4.12.3.6 [W/L/M]
see also : which
executeSection(
<string expr with section call> )
//since 4.12.3.9 [W/L/M]
see also : executeSection
see also: ExecWith sections ExecWith [W/L/M]
see also: Winbatch sections Winbatch [W/L/M]
Regular expression related functions [W/L/M]:
General Info: : Regular expression related functions
isRegexMatch(<string>, <pattern>) : boolean
//since 4.12.1
see also : isRegexMatch
getSubListByContainingRegex(<pattern>, <target list>) : stringlist
//since 4.12.1
see also : getSubListByContainingRegex
getSubListByContainingRegex(<pattern list>, <target list>) : stringlist
//since 4.12.1
see also : getSubListByContainingRegex
getRegexMatchList(<pattern>, <target list>) : stringlist
//since 4.12.1
see also : getRegexMatchList
getRegexMatchList(<pattern list>, <target list>) : stringlist
//since 4.12.1
see also : getRegexMatchList
removeFromListByContainingRegex(<pattern>, <target list>) : stringlist
//since 4.12.1
see also : removeFromListByContainingRegex
removeFromListByContainingRegex(<pattern list>, <target list>) : stringlist
//since 4.12.1
see also : removeFromListByContainingRegex
stringReplaceRegex(<string>, <pattern>, <replacement string>) : string
//since 4.12.1
see also : stringReplaceRegex
stringReplaceRegexInList(<target list>, <pattern>, <replacement string>) : stringlist
//since 4.12.1
see also : stringReplaceRegexInList
Registry related functions [W]
getRegistryValue(
<keystr>, <varstr> )
: string //since 4.12.0.16 [W]
<access str> = one of 32bit, 64bit, sysnative ; default sysnative
see also : getRegistryValue
GetRegistrystringvalue("[key] var") : string
[W]
see also : GetRegistrystringvalue
GetRegistryStringValue32 ("[key] var") : string
//since 4.10.8 [W]
see also : GetRegistryStringValue32
GetRegistryStringValue64 ("[key] var") : string
//since 4.10.8 [W]
see also : GetRegistryStringValue64
GetRegistryStringValueSysNative ("[key] var") : string
//since 4.10.8 [W]
see also : GetRegistryStringValueSysNative
getRegistryKeyList32(
<regkey> ) : stringlist
//since 4.11.3 [W]
see also : getRegistryKeyList32
getRegistryKeyList64(
<regkey> ) : stringlist
//since 4.11.3 [W]
see also : getRegistryKeyList64
getRegistryKeyListSysnative(
<regkey> ) : stringlist
//since 4.11.3 [W]
see also : getRegistryKeyListSysnative
getRegistryKeyList(
<regkey>, <access str> ) : stringlist
//since 4.12.5.0 [W]
see also : getRegistryKeyList
getRegistryVarList32(
<regkey> ) : stringlist
//since 4.11.3 [W]
see also : getRegistryVarList32
getRegistryVarList64(
<regkey> ) : stringlist
//since 4.11.3 [W]
see also : getRegistryVarList64
getRegistryVarListSysnative(
<regkey> ) : stringlist
//since 4.11.3 [W]
see also : getRegistryVarListSysnative
getRegistryVarList(
<regkey>, <access str> ) : stringlist
//since 4.12.5.0 [W]
see also : getRegistryVarList
getRegistryVarMap32(
<regkey> ) : stringlist
//since 4.11.3 [W]
see also : getRegistryVarMap32
getRegistryVarMap64(
<regkey> ) : stringlist
//since 4.11.3 [W]
see also : getRegistryVarMap64
getRegistryVarMapSysnative(
<regkey> ) : stringlist
//since 4.11.3 [W]
see also : getRegistryVarMapSysnative
getRegistryVarMap(
<regkey>, <access str> ) : stringlist
//since 4.12.5.0 [W]
see also : getRegistryVarMap
RegKeyExists(
<regkey>[,<access str>]) : bool
//since 4.12.0.16 [W]
<access str> = one of 32bit, 64bit, sysnative ; default sysnative
see also : RegKeyExists
RegVarExists(
<regkey>, <var str>[,<access str>]) : bool
//since 4.12.0.16 [W]
<access str> = one of 32bit, 64bit, sysnative ; default sysnative
see also : RegVarExists
see also: Registry [W]
see also : Registry-Sections
see also : 64 bit
String handling functions [W/L/M]
see also : string
splitString (
<string1>, <string2> ) : stringlist
[W/L/M]
see also : splitString
set $list1$ = splitString ("\\server\share\dir","\")
splitStringOnWhiteSpace (
<string> ) : stringlist
[W/L/M]
see also : splitStringOnWhiteSpace
composeString (
<string list>, <Link> ) : string
[W/L/M]
see also : composeString
takeString (
<index>, <list> ) : string
[W/L/M]
see also : takeString
setStringInListAtIndex(
<newstring>,<list>,<indexstr> ) : stringlist
//since 4.11.6 [W/L/M]
see also : setStringInListAtIndex
takeFirstStringContaining(
<list>,<search string> ) : string
[W/L/M]
see also : takeFirstStringContaining
getIndexFromListByContaining(
<list> : stringlist, <search string> : string )
: <number> : string //since 4.12.0.13 [W/L/M]
see also : getIndexFromListByContaining
contains(
<str>, <substr> ) : bool
//since 4.11.3: true if <substr> in <str> [W/L/M]
see also : contains
isNumber(
<str> ) : bool
//since 4.11.3: true if <str> represents an integer [W/L/M]
see also : isNumber
trim(
<string> ) : string
[W/L/M]
see also : trim
lower(
<string> ) : string
[W/L/M]
see also : lower
upper(
<string> )
[W/L/M]
see also : upper
unquote(
<string>,<quote-string> ) : string
//since 4.11.2.1 [W/L/M]
see also : unquote
unquote2(
<string>,<quote-string> ) : string
//since 4.11.5.2 [W/L/M]
see also : unquote2
stringReplace(
<string>, <oldPattern>, <newPattern> ) : string
//since 4.11.3 [W/L/M]
see also : stringReplace
strLength(
<string> ) : string (number)
//since 4.11.3 [W/L/M]
see also : strLength
strPos(
<string>, <sub string> ) : string (numner)
//since 4.11.3 [W/L/M]
see also : strPos
strPart(
<string>, <start pos>, <number of chars> ) : string
//since 4.11.3 [W/L/M]
see also : strPart
getValue(
<key string>, <hash string list> ) : string
[W/L/M]
see also : getValue
getValueBySeparator(
<key string>,<separator string>,<hash string list> ) : string
//since 4.11.2.1 [W/L/M]
see also : getValueBySeparator
getValueFromFile(
<key string>, <file name> ) : string
//since 4.11.4.4 [W/L/M]
see also : getValueFromFile
getValueFromFileBySeparator(
<key string>,<separator string>,<file name> ) : string
//since 4.11.4.4 [W/L/M]
see also : getValueFromFileBySeparator
EscapeString:
<sequence of characters> : string
// [W/L/M]
see also : EscapeString
stringReplaceRegex(<string>, <pattern>, <replacement string>) : string
//since 4.12.1 [W/L/M]
see also : stringReplaceRegex
stringinput(
< message str>,< boolstr confidential> ) : string
//since 4.12.1.2 [W/L/M]
see also : stringinput
Stringlist handling functions [W/L/M]
see also : stringlist
getListContaining(
<list>,<search string> ) : stringlist
[W/L/M]
see also : getListContaining
getListContainingList(
<list1>,<list2> ) : stringlist
//since 4.11.3.7 [W/L/M]
see also : getListContainingList
getIndexFromListByContaining(
<list> : stringlist, <search string> : string )
: <number> : string //since 4.12.0.13 [W/L/M]
see also : getIndexFromListByContaining
count (
<list> ) : string (number)
[W/L/M]
see also : count
emptylist (
<list> ) : stringlist
//since 4.11.3.7 [W/L/M]
see also : emptylist
for %
<identifier> % in
<list> do
<one statement | sub section> [W/L/M]
for %s% in $list1$ do sub_test_string
see also : opsi-script-stringlist-iteration
createStringList (
<string0>, <string1> ,… ) : stringlist
[W/L/M]
set $list1$ = createStringList ('a','b')
see also : createStringList
reverse (
<list> ) : stringlist
[W/L/M]
see also : reverse
getSubList (
<start index> : <end index>, <list> ) : stringlist
[W/L/M]
see also : getSubList
getSubListByMatch (
<search string>, <target list> )
:stringlist //since 4.12.0.14 [W/L/M]
see also : getSubListByMatch_sl
getSubListByMatch (
<search list>, <target list> )
:stringlist //since 4.12.0.14 [W/L/M]
see also : getSubListByMatch_ll
getSubListByContaining (
<search string>, <target list> )
:stringlist //since 4.12.0.14 [W/L/M]
see also : getSubListByContaining_sl
getSubListByContaining (
<search list>, <target list> )
:stringlist //since 4.12.0.14 [W/L/M]
see also : getSubListByContaining_ll
getSubListByKey (
<search string>, <target list> )
:stringlist //since 4.12.0.14 [W/L/M]
see also : getSubListByKey_sl
getSubListByKey (
<search list>, <target list> )
:stringlist //since 4.12.0.14 [W/L/M]
see also : getSubListByKey_ll
getKeyList (
<list> )
:stringlist //since 4.12.0.14 [W/L/M]
see also : getKeyList
addtolist(
<list>,<string> ) : stringlist
//since 4.10.8 [W/L/M]
see also : addtolist
addListToList(
<dest list>,<src list> ) : stringlist
//since 4.10.8 [W/L/M]
see also : addListToList
reencodestrlist(
<list>, <from>, <to> ) : stringlist
//since 4.11.4.2 [W/L/M]
see also : reencodestrlist
removeFromListByContaining(
<search string> ,
<target list> ) : stringlist
//since 4.11.5.1 [W/L/M]
see also : removeFromListByContaining_str
removeFromListByContaining(
<search list> ,
<target list> ) : stringlist
//since 4.11.5.1 [W/L/M]
see also : removeFromListByContaining_list
removeFromListByMatch(
<searchstring>,<target list> ) : stringlist
//since 4.11.6 [W/L/M]
see also : removeFromListByMatch
takeString (
<index>, <list> ) : string
[W/L/M]
see also : takeString
takeFirstStringContaining(
<list>,<search string> ) : string
[W/L/M]
see also : takeFirstStringContaining
setStringInListAtIndex(
<newstring>,<list>,<indexstr> ) : stringlist
//since 4.11.6 [W/L/M]
see also : setStringInListAtIndex
jsonAsArrayToStringList(
<jsonstr> ) : stringlist
//since 4.11.6: [W/L/M]
see also : jsonAsArrayToStringList
jsonStringListToJsonArray(
<strlist> ) : jsonstr
//since 4.11.6: [W/L/M]
see also : jsonStringListToJsonArray
jsonAsObjectGetKeyList(
<jsonstr> ) : stringlist
//since 4.11.6: [W/L/M]
see also : jsonAsObjectGetKeyList
splitString(
<string1>, <string2> )
: stringlist [W/L/M]
set $list1$ = splitString ("\\server\share\dir","\")
see also : splitString
splitStringOnWhiteSpace (
<string> ) : stringlist
[W/L/M]
see also : splitStringOnWhiteSpace
composeString(
<string list>, <Link> ) : string
[W/L/M]
see also : composeString
getValue(
<key string>, <hash string list> ) : string
[W/L/M]
see also : getValue
getValueBySeparator(
<key string>,<separator string>,<hash string list> ) : string
//since 4.11.2.1 [W/L/M]
see also : getValueBySeparator
setValueByKey(
<key>, <value>, <targetlist> )
: stringlist [W/L/M]
see also : prim-section.adoc#setValueByKey
getSubListByContainingRegex(<pattern>, <target list>) : stringlist
//since 4.12.1
see also : getSubListByContainingRegex
getSubListByContainingRegex(<pattern list>, <target list>) : stringlist
//since 4.12.1
see also : getSubListByContainingRegex
getRegexMatchList(<pattern>, <target list>) : stringlist
//since 4.12.1
see also : getRegexMatchList
getRegexMatchList(<pattern list>, <target list>) : stringlist
//since 4.12.1
see also : getRegexMatchList
removeFromListByContainingRegex(<pattern>, <target list>) : stringlist
//since 4.12.1
see also : removeFromListByContainingRegex
removeFromListByContainingRegex(<pattern list>, <target list>) : stringlist
//since 4.12.1
see also : removeFromListByContainingRegex
stringReplaceRegexInList(<target list>, <pattern>, <replacement string>) : stringlist
//since 4.12.1
see also : stringReplaceRegexInList
editmap(
< strlist> ) : stringlist
//since 4.12.1.2 [W/L/M]
see also : editmap
areListsEqual(
< strlist1>, <strlist2>, <flag> ) : boolean
see also : areListsEqual
GetSectionFromInifile(
<ini-file> ) : stringlist
[W/L/M]
see also : GetSectionFromInifile
Time / Date related functions [W/L/M]
sleepSeconds
<Integer> or <string> : noresult [W/L/M]
breaks the program execution for <string> seconds. <string> has to represent an Integer Value
see also : sleepSeconds
markTime
: noresult [W/L/M]
sets a time stamp for the current system time and logs it.
see also : markTime
getDiffTimeSec : string
(Time in seconds since last marktime) //since 4.11.3 [W/L/M]
see also : getDiffTimeSec
timeStampAsFloatStr : string
(Floating Number - format: 'days.decimal days') //since 4.11.6 [W/L/M]
see also : timeStampAsFloatStr
Usercontext / loginscripts related functions [W]:
GetUserSID(
<Windows Username> ) : string
see also : GetUserSID
GetLoggedInUser : string
//since 4.11.1.2
see also : GetLoggedInUser
GetUsercontext : string
//since 4.11.1.2
see also : GetUsercontext
GetScriptMode : string
possible values 'Machine','Login' //since 4.11.2.1
see also : GetScriptMode
saveVersionToProfile : noresult
- save productversion-packageversion to local profile //since 4.11.2.1
see also : saveVersionToProfile
readVersionFromProfile : string
- read productversion-packageversion from local profile //since 4.11.2.1
see also : readVersionFromProfile
scriptWasExecutedBefore : boolean
- is true if saved and running productversion-packageversion are identical //since 4.11.2.1
see also : scriptWasExecutedBefore
XML related functions (XML2) [W/L/M]:
see also : opsi-script-xml2-functions
getXml2DocumentFromFile(
<path to xml file> ) : xml2stringlist
//since 4.12.1
see also : getXml2DocumentFromFile
getXml2Document(
<stringlist wit xml> ) : xml2stringlist
//since 4.12.1
see also : getXml2DocumentFromFile
xml2GetFirstChildNodeByName(
<xml2stringlist>, <node name str> ) : xml2stringlist
//since 4.12.1.
see also : xml2GetFirstChildNodeByName
getXml2UniqueChildnodeByName(
<xml2stringlist>, <node name str> ) : xml2stringlist
//since 4.12.1.
see also : getXml2UniqueChildnodeByName
getXml2AttributeValueByKey(
<xml2stringlist>, <attr name str> ) : string
//since 4.12.1.
see also : getXml2AttributeValueByKey
getXml2Text(
<xml2stringlist> ) : string
//since 4.12.1.
see also : getXml2Text
see also : XML2 Sections [W/L/M]
see also : XML2 Section
TOML files related functions [W/L/M]:
see also : opsi-script-toml-functions
LoadTOMLFile(
<TOMLfilePath: String> ) : StringList
//since 4.12.5
see also : LoadTOMLFile
ReadTOMLFile(
<TOMLfilePath: String> ) : String
//since 4.12.5
see also : ReadTOMLFile
GetTOMLAsStringList(
<TOMLcontents: String> ) : StringList
//since 4.12.5
see also : GetTOMLAsStringList
GetTOMLAsString(
<TOMLcontents: String> ) : String
//since 4.12.5
see also : GetTOMLAsString
GetTOMLKeys(
<TOMLcontents: String> ) : StringList
//since 4.12.5
see also : GetTOMLKeys
GetTOMLTableNames(
<TOMLcontents: String> ) : StringList
//since 4.12.5
see also : GetTOMLTableNames
GetTOMLTable(
<TOMLcontents: String> , <table name : String> ) : StringList
//since 4.12.5
see also : GetTOMLTable
GetTOMLTableAsString(
<TOMLcontents: String> , <table name : String> ) : String
//since 4.12.5
see also : GetTOMLTableAsString
GetValueFromTOML(
<TOMLcontents: String> , <keyPath: String> , <defaultValue: String> ) : String
//since 4.12.5
see also : GetValueFromTOML
ModifyTOML(
<TOMLcontents: String> , <command: String> , <keyPath: String> , <value: String> ) : String
//since 4.12.5
see also : ModifyTOML
DeleteTableFromTOML(
<TOMLcontents: String> , <tablePath: String> ) : String
//since 4.12.5
see also : DeleteTableFromTOML
SaveToTOMLFile(
<TOMLcontents: String> , <TOML file Path: String> ) : boolean
//since 4.12.5
see also : SaveToTOMLFile
ConvertTOMLtoJSON(
<TOMLcontents: String> ) : String
//since 4.12.5
see also : ConvertTOMLtoJSON
ConvertTOMLfileToJSONfile(
<TOMLfilePath: String> , <JSONfilePath: String> ) : boolean
//since 4.12.5
see also : ConvertTOMLfileToJSONfile