Script Syntax


Contents

 

 

Overview


Script files use a very simple to understand language to run their commands and actions.

In general terms these files use the extension .script and can be edited with any text editor or using the internal editor from WinBuilder.

Settings are written in the form of Key=Value (e.g. Color=Blue) and these values are kept inside sections (e.g. [MySection]).

You can also add additional files inside your scripts and these files are stored as attachements in a process very similar to popular email messages. This way you can share your scripts in discussion forums with all the needed tools inside.

With this .script language you can copy files, create folders, write values on the registry and do a whole lot more.


We'll start off with very simple descriptions of each command and then some quick examples so that you can easily start understanding and creating your own scripts.

 

 

 

Compatibility


This page is updated directly from the internet and some of the commands that you find mentioned here might have been added only on recent WinBuilder versions.

It is recommended to use the latest versions to ensure the best results.

 

 

 

Usage



Overview



Script files can perform both specific and generic functions.

Some scripts will be responsible for creating the base structure of the project while others will be used to add extra functionality and programs.

These scripts can also use a very specific model that only works on a single project and cannot be sucessfully used on another project unless it also shares the same model as the original project from where it came. The model consists of functions and variables stored in scripts.

An effort is being made to create a generic sort of script to add programs across different projects, please read the script applications page for more details.


Sections



We use sections to group commands and settings inside script files. The easiest way to see how they are applied is to edit a few scripts and look at the source code to learn more about them.


A typical script is composed by 3 important sections


Script.project has two optional sections


Here is a small example of how it should look:

[Main]
Title=Add my Program
Description=This script will add my program
Level=5

[Variables]
%myTitle%="This is a title for the program"

[Process]
echo,%myTitle%

....
....
We can additionally use more sections to add variables from the script interface or even specify more sections with commands to be processed. We'll detail this further in these pages.

The [Interface] section is also important to scripts but we'll soon be referring to it in another chapter.


[Main] section



Inside this main section you can store the definitions that identify your script and allow it to be properly categorized inside the project. This section works like a normal INI section where you write all your data in the form of Key=Value (e.g. Color=Blue)

List of available keys



All of these keys can be edited easily using the wb's internal editor

These keys are optional, but it is recommended to place at least a few keys to better describe your script to others.


Some keys are assumed with default values if they are not found inside the script

 


[Variables] section



This section is described in more detail here


[Process] section



All commands you write in this section will be executed by the program.

From this section you can also call other sections using the run command from the same script or other scripts if necessary.

The result of each operation is written on the log window - which you can later view or save to an html page.


[OnProcessEntry] section



This section is an optional secial section exclusive in script.project.

If it is present, during build this section is processed beforet the first [Process] line of every processed script.


[OnProcessExit] section



This section is an optional secial section exclusive in script.project.

If it is present, during build this section is processed after the last [Process] line of every processed script.

Example:
[OnProcessExit]
Run,%ProjectDir%\script.project,Process-log


Levels



Levels is a feature from scripts that allow you to choose when your script should run while the project is being built.

You can select values between 1 and 10, when the project starts it will begin with the scripts that have the lower level number and will increase a level after all scripts with the previous levels are processed.

This is a very useful way to ensure that your script always runs at the correct time. First levels are usually used to be build the structure of your project, while the last levels are the ones where your project is finished and an image is created.

By default, we use level 5 as the middle value where most scripts that are only meant to add programs should be processed.

To further categorize and group your scripts you can also create subfolders and in this way ensure that these scripts are separated from others with the same level. Look for examples on the available projects to understand more about these filters.

Comments



Comment lines are skipped during processing.
Comment lines start with two slashes.

Syntax example:
// This is a comment line
 

Out of compatibility reasons also two hash marks are accepted as comment marker.

Syntax example:
## This is a comment line, too

 

 

 

Syntax



First some general rules and explanations:

  1. Besides some special cases (e.g. parameters in ShellExecute) generally enclosing quotes are not needed.
  2. Enclosing quotes MUST be used if the WinBuilder Script Line Parameters contain spaces.
    If the spaces are replaced by the escape #$s, the enclosing quotes should be ommitted.
  3. WinBuilder Script Line Parameters are separated by a comma.
    If a comma is inside an argument, it must be 'escaped' by #$c.
In most cases user violation of that rules are accepted by WinBuilder and processed as assumed.
E.g. unnecessary enclosing quotes or a comma inside an item enclosed by quotes.

But sometimes that can bring unexpected results.

.script language commands are very dependent on the use of variables to make them more flexible, please read the respective variables page for additional information.

All available commands are described on a single page so that you can later print this page to use as reference.

Usually all command which compare etc. are case insensitive.

There are some commands having a "X" at the end.

These commands work like that ones without the "X", but case sensitive.

 


.script commands can be grouped under the following categories


 

File Operations

Commands under this category were designed to handle files and are particularly useful to create the base structure of your project or add additional features that you need.

List of available functions

 

 


FileCopy


FileCopy,<FromFile>,<ToDir>
This command will copy a single source file to a specified destination.
If the destination is a folder name, the file is copied there.
If the destination is a file name, the file is copied into the destination folder and finally renamed.

The command uses Win32 API as a silent operation overwriting any previously existent files. You can view the result of this operation on the respective log entry.

WB076 added:
FileCopy of a single file gives a warning in the log, if the destination file already exists.

WB078 added:
If there is a parameter
PRESERVE added, FileCopy of a single file does not overwrite an existing file. A warning is still given
The warning can be suppressed by an additional parameter 
NOWARN

The parameters
PRESERVE, and NOWARN can be used simultaneously. The order does not matter.

Syntax example:
FileCopy,c:\MyPath\myText.txt,c:\AnotherPath,PRESERVE
Wildcards
FileCopy supports wildcards like *.* , win*.dll.
Then the command will copy all suited files and respective sub folders from a given source to a specified destination directory.
In case of using wildcars the warning mechanism is switched off.

Trying do copy wildcard source to a destination file raises an error.

WB078 added:
In case of wildcards optionally parameters can be defined:
SHOW: The progressbar shows single file processing, and the actual copied file name is shown. NOREC: Only all suited files of the initial folder are copied. No recursion into subdirectories.

The parameters 
SHOW  and NOREC can be used simultaneously. The order does not matter.

Syntax example:
FileCopy,c:\MyPath\*.txt,c:\AnotherPath

On this example FileCopy will copy all text files (*.txt) from MyPath and it's subdirectories to AnotherPath


FileDelete


FileDelete,<FileToDelete>
This command will delete files. It uses Win32 API as a silent operation deleting all files that match the search criteria. You can view the result of this operation on the respective log entry. Beware that all deleted files are immediately removed instead of moved to the recycle bin.

FileDelete supports wildcards ( *.* )

Syntax example:
FileDelete,c:\MyPath\*.txt

In this example FileDelete will delete all text files (*.txt) from MyPath


FileRename


FileRename,<OldFilename>,<NewFilename>
This command will rename a single file

Syntax example:
FileRename,c:\MyPath\myTextFile.txt,c:\MyPath\myOldTextFile.txt

In this example FileRename will rename c:\MyPath\myTextFile.txt to another filename as myOldTextFile.txt


FileCreateBlank


FileCreateBlank,<NewFile>
This command simply creates a new empty file with the filename you specify. If a file with the same filename already exists it will be overwritten.


WB078 added:
FileCreateBlank gives a warning in the log, if the destination file already exists.
If there is a parameter
PRESERVE added, FileCreateBlank does not truncate an existing file. A warning is still given
The warning can be suppressed by an additional parameter 
NOWARN

The parameters
PRESERVE, and NOWARN can be used simultaneously. The order does not matter.

Syntax example:
FileCreateBlank,c:\MyPath\MyNewFile.txt

In this example FileCreateBlank will create an empty file called MyNewFile.txt


FileByteExtract


FileByteExtract,<FilesToSearch>,<OutputFile>,<ByteSignature>,<BytesLength>
This is a command with a very specific function. It will look inside all files that match the search criteria for a specific byte signature.

Byte signatures are specified in groups of two digits that are expressed in hexadecimal format. Possible value range from combinations starting at 00 and ending at FF

If this byte sequence is found, then it will copy a specific number of bytes and save them as a new file.

The bytes that compose the signature are also the header bytes on the new file.

This command was originally designed to find a byte sequence inside some system files that contained resources. Please look in the forums for practical examples of usage.

Syntax example:
FileByteExtract,c:\MyPath\*.*,c:\MyPath\NewFile.bin,001122334455,1440000

In this example, if a match is found then a new file will be created with the size specified in BytesLength

DirCopy


DirCopy,<FromDir>,<ToDir>
This command will copy a folder and respective sub folders from a given source to a specified destination. It uses Win32 API as a silent operation overwriting any previously existent folder.

Syntax example:
DirCopy,c:\MyPath,c:\AnotherPath

In this example DirCopy will copy the complete directory MyPath to AnotherPath

DirCopy,c:\MyPath\*.*,c:\AnotherPath

In this example DirCopy will copy all files and directories inside MyPath to AnotherPath


WB078 added:
The optional parameter 
SHOW can be added. That will open the Windows internal progress window.

DirDelete


DirDelete,<DirToDelete>
This command will delete a folder and respective files and folders inside. It uses Win32 API as a silent operation to delete the specified folder. Beware that deleted folders are not recoverable from the recycle bin.

Syntax example:
DirDelete,c:\MyPath

In this example DirDelete will remove MyPath
WB076 added:
The optional parameter
FAST can be added. That will rename the directory to a random name, and then delete in the background.

DirMove


DirMove,<MoveDir>,<ToDir>
This command will move a folder and respective sub folders from a given source to a specified destination. It uses Win32 API as a silent operation overwriting any previously existent folder.

The previous location ceases to exist with this folder being found under the new location

Syntax example:
DirMove,c:\MyPath,c:\AnotherPath

In this example DirMove will move MyPath to AnotherPath


DirMake


DirMake,<NewDir>
This command will create a new folder as you specify.

Syntax example:
FileCreate,c:\MyPath

In this example FileCreate will add a new directory called MyPath


CopyOrExpand


CopyOrExpand,<FileToCopyOrExpand>,<DestinationFolderOrFilename>
This is a very flexible command that is designed for cases where we can either need to Copy or Expand a file.

It was implemented to ease the task of copying files from Install CD's where often a specified can be present either in normal format or compressed.

These compressed files use the cabinet archiving method and usually have an identifiable _ as the last character on their extensions. (e.g. myFile.Tx_ ). When this file is expanded a new file with a full extension is retrieved.

DestinationFolderOrFilename
means that you can either specify a folder where this file will be placed with the original (expanded) filename or new filename that you prefer.
Syntax example:
CopyOrExpand,c:\MyPath\myTextFile.txt,c:\MyPath\myNewerTextFile.txt

In this example CopyOrExpand will first try to find a file c:\MyPath\myTextFile.txt and if it is not found then it will look for c:\MyPath\myTextFile.tx_ and expand this file if successfully found.
WB078 added:
CopyOrExpand gives a warning in the log, if the destination file already exists.
If there is a parameter
PRESERVE added, CopyOrExpand of a single file does not overwrite an existing file. A warning is still given
The warning can be suppressed by an additional parameter 
NOWARN

The parameters
PRESERVE, and NOWARN can be used simultaneously. The order does not matter.

Expand


Expand,<CABfile>,<DirToDecompress>
This command will decompress all files inside CABfile to the folder you specify.

Cabinet files usually use extension .CAB

Syntax example:
Expand,c:\MyPath\MyFile.cab,c:\MyNewPath

In this example Expand will try to expand all files found inside c:\MyPath\MyFile.cab to the folder c:\MyNewPath
WB078 added:
A single file can be extracted from the cab file, by giving it's name as third parameter

Syntax example:
Expand,c:\MyPath\MyFile.cab,c:\MyNewPath,YourFile.dll

Expand of a single file gives a warning in the log, if the destination file already exists.
If there is a parameter
PRESERVE added, Expand of a single file does not overwrite an existing file. A warning is still given
The warning can be suppressed by an additional parameter 
NOWARN

The parameters
PRESERVE, and NOWARN can be used simultaneously. The order does not matter.

Registry Handling


These commands are written to write and read values from the local registry on your windows machine. You can also load the hives from the projects being built at any given time.

These registry operations are valid for any Windows Platform, you should however note that Vista restricts the specific operation to load/unload hives - it is necessary to disable the UAC (User Account Control) before running projects that need this support.

List of available functions


RegWrite


RegWrite,<HKEY>,<KeyType>,<Section>,<Keyname>,<Value>
This command will create a new registry entry as specified.

HKEY
is the "Hive Key" where the key is to be placed. These hives are files that are loaded by your machine when booting and compose the registry structure. By default, most scripts use HKLM as the work hive.

Valid HKEY values


Details on the functions of each hive can be found at the Microsoft Site.


Keytype will specify how the data in the registry key should be interpreted.

Valid key type values



Section is the complete path to the section where the key is supposed to be written

Keyname and value are similar to the method for INI files, please ensure that the value you use is compatible with the key type.

Creating an empty section: Write a key using keytype as 0x1 and omit the entries for key and value - this will create a new section at the location you specify.


Syntax example:
RegWrite,HKLM,0x4,Build\ControlSet001\Services\VgaSave\Device0,DefaultSettings.XResolution,1024
The above example writes a numeric key with the value 1024
WB078 added:
RegWrite gives a warning in the log, if the destination value already exists.
If there is a parameter
PRESERVE added, RegWrite does not overwrite an existing value. A warning is still given
The warning can be suppressed by an additional parameter 
NOWARN

The parameters
PRESERVE, and NOWARN can be used simultaniously. The order does not matter.

RegRead


RegRead,<HKEY>,<Section>,<Key>,<%Variable%>
This command will read a value from the key you specify.

It uses the same components as described above with the difference that it will copy the value of a key into a variable.

This command will only retrieve values from the following keytypes:


WB078 added:
All key types are supported now.

Syntax example:
RegRead,HKLM,Build\ControlSet001\Services\VgaSave\Device0,DefaultSettings.XResolution,%myXresolution%
In this example the variable %myXresolution% will store the value of the mentioned key


RegDelete


RegDelete,<HKEY>,<Section>,<Key>
This command will delete the key you specify.

It uses the same components as described above with the difference that it will delete a key from the registry.

Syntax example:
RegDelete,HKLM,Build\ControlSet001\Services\VgaSave\Device0,DefaultSettings.XResolution
In this example the specified key will be deleted

WB076 added:
RegDelete,<HKEY>,<Section>

This command will delete the section you specify.

Syntax example
:
RegDelete,HKLM,Build\ControlSet001\Services\VgaSave\Device0

RegHiveLoad


RegHiveLoad,<SectionName>,<HiveFilename>
This command will load an external registry hive onto your local registry system.

It is particularly useful to allow editing the hives of project when they are being built. Most scripts usually load the needed hives for editing and after writing all necessary data are properly unloaded (command described below).

This command is based on Windows 32bit API and works under any Windows platform - under Vista it is necessary to disable the UAC (User Account Control).

Syntax example:
RegHiveLoad,Build,%targetdir%\I386\system32\setupreg.hiv
In this example we will load the setupreg.hiv hive file from our work folder and place it under a registry section called Build


RegHiveUnload


RegHiveUnload,<SectionName>
This command will unload an external registry hive from your local registry system that was previously loaded with the RegHiveLoad command or with another application capable of handling external hives.

This is an obligatory step whenever you use the RegHiveLoad command otherwise your project might fail to be properly completed.

It will use as parameter the section name where the previously loaded hive was placed.

This command is based on Windows 32bit API and works under any Windows platform - under Vista it is necessary to disable the UAC (User Account Control).

Syntax example:
RegHiveUnload,Build
In this example we will unload the setupreg.hiv hive file that has been loaded under registry section Build as described above.


RegImport


RegImport,<RegFileToImport>
This command will import an external registry file (*.reg) to your local registry system.

It will use as parameter the  filename to read values from.

Syntax example
:
RegImport,c:\myFile.reg
In this example we add the values from myFile.reg onto the registry system

Ini manipulation


This category contains commands that were created to work with INI based text files.

INI consists in grouping information using a few rules, it is also very easy to understand and edit when needed.

We use INI files to exchange information between scripts or store data whenever needed. In most cases INI language files use extension .ini - but our commands are not limited to just this type of extension and can be used on any text file that uses a INI derivated language like .script language.


Quick explaining some INI concepts:


Available INI functions


IniWrite


IniWrite,<Filename>,<Section>,<Key>,<Value>
This command will write the key and value on the section inside the file you specify.

Syntax example:
IniWrite,C:\myFile.ini,mySection,myKey,myValue
In this example the specified myKey and respective myValue will be written in the section mySection in C:\myFile.ini

IniRead


IniRead,<Filename>,<Section>,<Key>,<%variable%>
This command will read the key from a section inside a file that you specify.

Syntax example:
IniRead,C:\myFile.ini,mySection,myKey,%myVariable%
In this example the value of the specified key will be stored inside %myVariable%
IniDelete


IniDelete,<Filename>,<Section>,<Key>
This command will delete the key from a section inside a file that you specify.

Syntax example:
IniDelete,C:\myFile.ini,mySection,myKey
In this example the specified key and respective value will both be deleted

IniAddSection


IniAddSection,<Filename>,<Section>
This command will add a new section inside the file you select.

If this section already exists - no action will take place otherwise it will create a new empty section in the respective text file.


Syntax example:
IniAddSection,C:\myFile.ini,mySection
In this example we're adding a new section.


IniDeleteSection


IniDeleteSection,<Filename>,<Section>
This command will delete a given section inside the file you select.

All keys and values inside this section are completely removed as well.

Syntax example:
IniDeleteSection,C:\myFile.ini,mySection
In this example we're deleting an existing section.

IniWriteTextLine


IniWriteTextLine,<Filename>,<Section>,<StringLine>
This command will add a text line to given section inside the file you select.

This line is placed on the top of the section.

Syntax example:
IniWriteTextLine,C:\myFile.ini,mySection,ThisIsMyLine
In this example a new line is added on the top of the section and all remaining lines are moved below.

WB078 added:
Optional APPEND argument

Syntax example:
IniWriteTextLine,C:\myFile.ini,mySection,ThisIsMyLine,APPEND
In this example the new line is added on the end of the section

IniMerge


IniMerge,<UpdatedINIfile>,<INIfileToUpdate>
This command will update all values from a INI file based on the contents from another INI file.

All Sections are compared inside both files and newer keys or items with different values are added to INIfileToUpdate

Syntax example:
IniMerge,C:\myNewValues.ini,mySection,ThisIsMyBaseFile.ini
In this example the command will read all keys found inside myNewValues.ini and if they aren't present, ThisIsMyBaseFile.ini will be added, overwriting older values if necessary.


 

Attachments


Attachments are files that can be included inside your script.

Since script files are meant to be edited by any text editor, these files are encoded in a process similar to email attachments.

This method allows to add small files along with your scripts in order to keep everything together.

While a script is running you can use some of the following commands to best take advantage of this feature.

List of related commands


ExtractFile


ExtractFile,<%ScriptFile%>,<Folder>,<Filename>,<DirToExtract>
This command will extract a single file from a folder inside a given script.



Syntax example:
ExtractFile,C:\myFile.script,Folder,myFile.txt,c:\
Using this example we will extract a given myFile.txt from myFile.script to c:\

ExtractAndRun


ExtractAndRun,<%ScriptFile%>,<Folder>,<Filename>[,<parameters>]
This command will run a file that is attached inside a script file.

Optional run parameters can be defined. They must not contain spaces, quotes or commas. Use the escapes #$s, #$q, #$c instead.


It is usefull when you only wish to run a file for a very specific purpose and this way avoid having to add extra commands to extract run and then delete the file from a temporary location when it is no longer needed.

Syntax example:
ExtractAndRun,C:\myFile.script,Folder,myApp.exe
Using this syntax we will extract myApp.exe to a temporary location and then delete this file when it has finished running.

ExtractAllFiles


ExtractAllFiles,<%ScriptFile%>,<Folder>,<DirToExtract>
This command will extract all files from a given folder inside a script.

Uses the same syntax as the ExtractFile command that extracts a single file, but with the advantage that you can extract all files from a folder without needing to specify any filenames.

Syntax example:
ExtractAllFiles,C:\myFile.script,Folder,c:\
Using this example we will extract all files found inside a folder in a given script file to c:\

ExtractAllFilesIfNotExist


ExtractAllFilesIfNotExist,<%ScriptFile%>,<Folder>,<DirToExtract>
This command uses the same syntax with the difference that it will  only extract files from a section in a given script if they aren't already found in DirToExtract

It was added to support cases where it is required to download only newer files and keep the older ones unchanged

Encode


Encode,<%ScriptFile%>,<Folder>,<Filenames>
This command will encode and add files inside a given folder to a script.

You can either specify a single filename or use wildcards that match a file criteria.

If the folder doesn't exist, it is created otherwise files are added to the already available folder.


Syntax example:
Encode,C:\myFile.script,Folder,c:\myApp.exe
With this syntax we add c:\myApp.exe inside Folder to C:\myFile.script

Text Files


With this set of commands we can handle text files and modify them as needed. All these commands can be applied to either a single or multiple file using wildcards.

Description of commands


TxtAddLine


TXTAddLine,<Filename>,<StringLine>,<Action>
With this command we can add a text line at a given location inside a text file, you can specify this location using an action option.

Action options


Syntax example:
TXTaddLine,C:\myFile.txt,Hello World!,place,5
With this syntax we add a line saying Hello World! in the 5th line counting from the top. If the text file doesn't have 5 lines, then it will be placed as the last line. There is no limit to this count value.

TxtReplace


TXTReplace,<Filename>,<OldString>,<NewString>
This command will look inside a given filename and replace all text that match the value of OldString and replace them with NewString

Syntax example:
TXTReplace,C:\myFile.txt,"Hello World!","Have a good day"
All matches to Hello World! within a text file will be replaced by Have a good day

TxtDelLine


TXTDelLine,<Filename>,<StringToDelete>
This command will look for lines that match the StringToDelete value and will remove these lines from the text file.

StringToDelete doesn't need to be the value of the entire line, it will only need to match the beginning of the line.

Syntax example:
TXTDelLine,C:\myFile.txt,Hello
All lines that start with Hello inside C:\myFile.txt will be removed.

TxtDelSpaces


TXTDelSpaces,<Filename>
This is a very simple command that will delete all spaces inside a text file. It was created to make some specific INI files smaller in overall size.

Syntax example:
TXTdelSpaces,C:\myFile.txt

TxtDelEmptyLines


TXTDelEmptyLines,<Filename>
With a similar function to the above detailed command, this function will remove all empty lines from a given text file.

Syntax example:
TXTdelEmptyLines,C:\myFile.txt

 

If Clauses


In .script language you can use If clauses to ease your life when running a script and to be able to evaluate certain conditions. 

If a condition is true when you test it with the IF command then a command will be executed.

General format:
If,<condition>,<command>
WB076 added second, optional line: Else,<command>

If a condition is false when you test it with the IF command then the second command will be executed.

<command> can be

    WB076 added:


List of available IF conditions


WB076 added:


IF Exist.. or IF NotExist..


If,<test>,<FilenameOrDirectory>,<Command>
You can use this test to determine if a file or directory exists in a given location. If this test is true, then a Command is executed.

When testing sections, you need to add the filename and then the section name.

Available tests



Syntax example:
If,NotExistFile,c:\myFile.txt,FileCreateBlank,c:\myFile.txt
In this given example we are testing if c:\myFile.txt does not exist. If this condition is true, then FileCreateBlank,c:\myFile.txt will be executed

IF Equal, Smaller, Bigger, NotEqual


If,<%var%>,<test>,<value>,<Command>
This set of IF clauses will test number values

Available tests


WB078 added:


Syntax example:
If,%myVariable%,Equal,10,FileCreateBlank,c:\myFile.txt
In this given example we are testing if %myVariable% is equal to 10. If this condition is true then FileCreateBlank,c:\myFile.txt will be executed

IF Ping


If,ping,<xxx.xxx.xxx.xxx>,<Command>
Ping will test if a given IP is valid and run a command if this test is true.

Syntax example:
If,ping,10.111.8.1,FileCreateBlank,c:\myFile.txt
In this given example we are pinging a machine on the network. If this condition is true then FileCreateBlank,c:\myFile.txt will be executed.
WB078 added:
Host domain name accepted

Syntax example:
If,ping,winbuilder.net,FileCreateBlank,c:\myFile.txt

IF Online


If,online,<Command>
Ping will test if the computer is online and run a command if this test is true.

Syntax example:
If,online,FileCreateBlank,c:\myFile.txt
In this given example we are checking if a machine is connected on a network. If this condition is true then FileCreateBlank,c:\myFile.txt will be executed.

IF License/NotLicense


If,License,<textfilename>,<Command>
This command was added to be used as tool to accept a license agreement whenever needed. It will open a special tab where the user has the option to read the terms of the license and then press a button corresponding to his decision to agree or not with the displayed terms.

TextFilename is the text file that will be displayed on the license window.

The option License runs a command when the user agrees with the license conditions and NotLicense will run a command if the user doesn't agree.

Syntax example:
If,NotLicense,c:\myEULA.txt,halt,"User doesn't agree with license."
This example will present the contents of myEula.txt - in case the user doesn't agree with this license the project build will be aborted.


IF ExistRegSection


If,ExistRegSection,<HKEY>,<Section>,<Command>
Syntax example:
If,ExistRegSection,HKLM,SOFTWARE\Classes\xyz,RegRead,HKLM,SOFTWARE\Classes\xyz,Language,%var%
This command will read the value of HKLM\SOFTWARE\Classes\xyz,Language, if RegSection HKLM\SOFTWARE\Classes\xyz  does exist.


IF ExistRegKey


If,ExistRegKey,<HKEY>,<Section>,<Key>,<Command>
Syntax example:
If,ExistRegKey,HKLM,SOFTWARE\Classes\xyz,Language,RegRead,HKLM,SOFTWARE\Classes\xyz,Language,%var%
This command will read the value of HKLM\SOFTWARE\Classes\xyz,Language, if RegKey HKLM\SOFTWARE\Classes\xyz,Language  does exist.


IF ExistVar/NotExistVar


If,ExistVar,<%var%>,<Command>
If,NotExistVar,<%var%>,<Command>
Syntax example: Set,%var%,NIL
If,ExistDir,C:\Program Files\IrfanView,Set,%Var%,1
If,ExistVar,%var%,Message,"'%var%' does exist",Information

In this given example we’ll check if the program path C:\Program Files\IrfanView does exist, if it’s true the value of %Var% will be set to 1. Then we’ll check if %Var% does exist, if it’s true a message windows with text ‘1’ does exist appears.


IF Not


If,Not,<Condition>,<Command>
Syntax example: If,Not,%var1%,EQUAL,%var2%,FileCreateBlank,C:\myFile.txt
In this given example the file c:\myFile.txt will be created if value of %var1% is different to value of %var2%.

Note:
If,Not,%var1%,EQUAL,%var2%,command is equivalent to If,%var1%,NOTEQUAL,%var2%,command
The current NOTEQUAL, NOTEXISTDIR, ... commands are still processes because of compatibility reasons.
But before processing they are internally changed into If,Not,...
Therefore:
If,NOT,%var%,NOTEQUAL,%test%,command is equivalent to If,%var1%,EQUAL,%var2%,command


If Question


If,QUESTION,<Question>,<Command>
As question, also all strings defined in the language files can be used like variables, identified by their ID number $#nnnn.

Syntax example: If,QUESTION,$#1541?,command (The question mark is part of the TEXT, not part of the ID!)

The resulting dialog box shows in case of default language (English):
Save changes to disk?
In case of e.g. italian language:
Salva cambiamenti al disco?
WB076 added:

Usually the question dialog waits for ever for the user's input.
You can cause to close it after a timeout, by adding the timeout (in seconds) and a default answer (Yes / No) as last arguments.
If,QUESTION,"Exit Script?",Exit,"User decided",10,yes


Else


If,<Condition>,<Command>
Else,<Command>
The Else command must follow the If command immediately.

Syntax example: If,Not,ExistFile,C:\myFile.txt,FileCreateBlank,C:\myFile.txt
Else,Message,"File already exists",INFORMATION
In this given example we are testing if c:\myFile.txt does not exist. If this is true, then FileCreateBlank,c:\myFile.txt will be executed, otherwise a message windows with text File already exists appears.

 

Retrieve Functions


This set of functions will enable you to get some specific values when running your script.

They can be grouped as


WB076 added:



Retrieve FolderSize/FileSize


Retrieve,FolderSizeOrFileSize,<DirectoryOrFilename>,<%var%>
This function is used to calculated sizes and store them inside variables.


Syntax example:
Retrieve,FolderSize,c:\myFolder,%var%
This example will write the size of myFolder as a new value for %var%


Retrieve File/Dir


Retrieve,File/Dir,<DirectoryOrFilename>,<%var%>
This function will bring a box asking the user to select a folder or a filename. Once a value is selected and the user clicks "Ok" to close the box, this value will be stored inside %var%


Syntax example:
Retrieve,File,c:\*.txt,%var%

You can use this example to open a box asking the user to select a file. This box will start in c:\ and will only display files that match the filter criteria which is *.txt on this case. Once a file is selected, the %var% will contain the full filename of this selected file.


Retrieve MD5


Retrieve,MD5,<Filename>,<%var%> MD5 is a way to calculate a number known as a 'hash' or 'checksum' that is based on the filesize of a file.

It is used as a safety check to ensure that files are complete when they are downloaded from a server. You can also call this function to ensure that your files were not modified.

Syntax example:
Retrieve,MD5,c:\MyText.txt,%var%

This function will write the value of the MD5 result on %var%, you can compare against a security value written elsewhere to prove that your file is intact.


Retrieve FileVersion


Retrieve,FILEVERSION,<Filename>,<%var%>
Syntax example: Retrieve,FILEVERSION,”c:\Program Files\IrfanView\i_view32.exe”,%var%
This example fills %var% with the file version string, as it can be seen by EXE-file’s properties.

String Format


This category details a command that is used to perform numeric calculations or extract specific details from a given text line (string).

List of available options


WB076 added:


WB078 added:


StrFormat INC/DEC/MULT/DIV


StrFormat,<Action>,<%var%>,<n> This option is used to modify the value of a given number based on the arithmetic operation you select. It's also important to specify the value to use to perform this operation (only positive values). The result is outputted to the used variable (%var%), negative numbers are supported by this variable value.
 
List of possible Action values


n is the last parameter on this command and should always be a numeric value.

Syntax example
:
StrFormat,Inc,%LoopAgain%,5

In this example we have a variable called %LoopAgain% with a value of 10. Once we increase the value of this value with the last parameter of this command we will get the same variable %LoopAgain% with a value of 15. This same example applies for all other available actions.



StrFormat FILENAME/PATH/EXT


StrFormat,<Action>,<Filename>,<%VarResult%> This option is used to extract specific information from the given text related to filenames.
 
List of possible Action values


Syntax example:
StrFormat,filename,c:\myPath\myFile.txt,%myVar%

This example will output to %myVar% a value of myFile.txt

WB076 added: The command now also can extract path, filename and extensions from URLs

Syntax example: Set,%DownloadURL1%,http://live.sysinternals.com/Bginfo.exe
StrFormat,PATH,%DownloadURL1%,%var1%
StrFormat,FILENAME,%DownloadURL1%,%var2%
StrFormat,EXT,%DownloadURL1%,%var3%
In this example we extract path, filename and extension from an URL with result

%var1%=http://live.sysinternals.com/
%var2%=Bginfo.exe
%var3%=.exe


StrFormat BYTES


StrFormat,bytes,<%VarResult%> This option is used to convert a specific number of bytes from the given text. to a human readable format. Any amount of bytes specified will be converted to Kb, Mb, Gb and Tb.

Syntax example:
StrFormat,bytes,1440000,%myVar%

In this example %myVar% will output a value of 1,44Mb


StrFormat DATE


StrFormat,Date,<%var%>,<yyyy-mmm-dd hh:nn am/pm> This option is used to retrieve the current hour and date and output it to a variable using the format you prefer.

The last parameter will define the way how these values will be written to your variable. You can omit values that aren't needed and even add custom text inside.

Syntax example:
StrFormat,date,%myVar%,yyyy-mmm-dd

In this example %myVar% will output the current year, month and day - for example: 2007-jun-07


StrFormat CEIL/FLOOR


StrFormat,<Action>,<%var%>,<%size%>
size may be:

number (e.g. 512)

character ‘k’ meaning 1024 (= kilobyte)

character ‘m’ meaning 1024 * 1024  (= megabyte)

List of possible Action values


Syntax example: Set,%var%,37
Set,%size%,10
StrFormat,CEIL,%Var%,%size%
In this given example we are rounding up the value of %var% to the next multiple of %size%. The result is filled into %var% with the value of 40.


StrFormat LTRIM/RTRIM/CTRIM/NTRIM


StrFormat,<Action>,<%string%>,<CharsToTrim>,<%var%>
List of possible Action values

Syntax example: Set,%string%,tomorrow
StrFormat,LTRIM,%string%,3,%var%
In this example we have a given string tomorrow  and we trim 3 chars from the left. The remaining rest is filled into %var% with value orrow.
The same syntax applies for StrFormat,RTRIM trimming 3 chars from the right resulting as tomor.

Set,%string%,Programs\
StrFormat,CTRIM,%string%,\,%var%
This option is used to trim the first and/or the last char of a given string if the char to trim is matching with the first and/or the last char of the string.
If the char does not exist the string remains unchanged.
In this example we trim the backslash of given string Programs\ with result Programs.

StrFormat,NTRIM,pTextBox12,%var%
This option is used to trim numbers from the end of a string.
It can be used to extract the class name from interface components.
Here %var% will contain: pTextBox


StrFormat LEFT/RIGHT


StrFormat,<Action>,<%string%>,<CharsToObtain>,<%var%>
List of possible Action values

Syntax example: Set,%string%,tomorrow
StrFormat,LEFT,%string%,3,%var%
In this example we have a given string tomorrow  and we want to get 3 chars from the left filled into %var% with value  tom.
The same syntax applies for StrFormat,RIGHT with result row.


StrFormat MID


StrFormat,MID,<%string%>,<PositionOfFirstChar>,<CharsToObtain>,<%var%>
Syntax example: Set,%string%,tomorrow
StrFormat,MID,%string%,3,4,%var%
In this example we have a given string tomorrow  and we want to get 4 chars beginning with the third char. The result is filled into %var% with value  morr.


StrFormat REPLACE


StrFormat,REPLACE,<%string%>,<CharsToReplace>,<ReplacementChars>,<%VarResult%>
Syntax example: Set,%a%,BROWN
Set,%b%,yellow
Set,%source%,”The quick brown fox jumps over the lazy dog”
StrFormat,REPLACE,%source%,%a%,%b%,%VarResult%
StrFormat,REPLACEX,%source%,%a%,%b%,%VarResultSens%
In the first example we replace (case insensitive) brown by yellow resulting as new string in %VarResult%:
The quick yellow fox jumps over the lazy dog
In the second example there is nothing replaced, because uppercase brown is not found, resulting the original string in %VarResultSens%:
The quick brown fox jumps over the lazy dog


StrFormat SPLIT


StrFormat,SPLIT,<%string%>,<DelimiterChar>,<Index>,<%VarResult%> (Index=0 --> number of items)

Syntax example: Set,%source%,”The quick brown fox jumps over the lazy dog”
StrFormat,SPLIT,%source%,#$s,0,%count%
Loop,%ScriptFile%,Section,1,%count%

[Section]
StrFormat,SPLIT,%source%,#$s,#c,%VarResult%
In this example we split the string “The quick brown fox jumps over the lazy dog” using the delimiter space (#$s) and get the single words in the separate loop passes.


StrFormat SHORTPATH/LONGPATH


StrFormat,<Action>,<%string%>,<%VarResult%>
List of possible Action values

This will return the DOS 8.3 path ot the NT style path.

 

StrFormat CHARTOOEM/OEMTOCHAR


StrFormat,<Action>,<%string%>,<%VarResult%>
List of possible Action values

Syntax example: StrFormat,CHARTOOEM,'aüöäasf',%var1%
StrFormat,OEMTOCHAR,%var1%,%var2%
In this example we change the german umlauts 'aüöäasf' (ANSI charset) into %var1% with result 'a”„asf' (DOS charset) and
%var1% into new %var2% with result 'aüöäasf'.

StrFormat LEN


StrFormat,LEN,<%string%>,<%VarResult%>
Syntax example: StrFormat,LEN,"Hello World",%var1% Returns 11 into %var1%


StrFormat POS


StrFormat,POS,<String>,<SubString>,<%VarResult%>
Syntax example: StrFormat,POS,”Hello World”,orl,%VarResult%
In this example we verify the position of (case insensitive) 'orl' in 'Hello World' with result 8.
StrFormat,POSX,”HELLO World”,l,%VarResult%
In this example we verify the position of lowercase 'l' in 'HELLO World' with result 10. 

Network Tools

Functions on this category allow you to work with the network environment whenever available.


WebGet / WebGetIfnotExist


WebGet,<FileToDownload>,<FileOnDisk>[,MD5]
WebGetIfNotExist,<FileToDownload>,<FileOnDisk>[,MD5]
WB076 added: WebGet,<FileToDownload>,<FileOnDisk>[,MD5][,Comment][,Timeout]]
WebGetIfNotExist,<FileToDownload>,<FileOnDisk>[,MD5][,Comment][,Timeout]]

Use this function to download files from a network server to the local machine. It is assumed that both machines (local and remote) are prepared for this operation.
No checks are done to ensure that the local machine is online or that is has enough disk space to download the file. The remote server must also be accessible and the file must be available for download.
Only direct download links are accepted, dynamic internet pages are not valid.
MD5 check is an additional parameter that is added to ensure that your file matches a security check based on the MD5 hash calculation. This is an optional parameter, only needed for cases when it is important to only accept a file that passes on this download integrity test. If  a file fails this test it won't be copied over to the final destination as FileOnDisk.
If the target filename folder doesn't exist, it will be created. If a file already exists it will be overwritten (read WebGetIfnotExist for alternative behavior)
The WebGetIfNotExist command will only download a file if it is not already found as FileOnDisk - particularly useful to download a zipped file once from an internet server and ignore on the following times the script is executed.
Syntax example: WebGet,http://boot-land.net/winbuilder/WinBuilder.exe,c:\WinBuilder\WinBuilder.exe Using this example we will download a WinBuilder.exe file from the server at boot-land.net to directory c:\WinBuilder.

Syntax example for enhanced WebGet functionality:
WebGet,http://irfanview.tu.wien.ac.at/iview423.zip,c:\IrfanView\iview423.zip,fd490d07cc236cb44ef29abfd9daf13d,ZIP-file,10
In this example we download the file iview423.zip from server irfanview.tu.wien.ac.at to folder c:\IrfanView\iview423.zip


To use optional comment the line Ask before ‘WebGet in Tab TOOLS\OPTIONS has to be checked.
To use optional timeout the line Use Timeout when asking in Tab TOOLS\OPTIONS has to be checked.

Miscellaneous Commands

Under this category you find the commands which aren't grouped under any specific category but are still quite used on most scripting tasks.


WB076 added:


Run / Exec


Run,%ScriptFile%,<Section>[,parameters]
Exec,%ScriptFile%,<Section>[,parameters]
This command is used to run the commands found in a section inside a script file. You can run sections from any script including the script from where run is originally called. Use %scriptFile% as a parameter to call another section found inside the same script.

By default this command willl use the same variables available in the original script from where it was 

called. If you wish to load the variables from the external script then you should use Exec.

Syntax example:

run,%scriptfile%,mySection

In this example we run a section called mySection inside the same script file Parameters support
This command also allows you to use parameters - this is a very useful feature to create a section that works based on these variables and this way avoid the need to add very long similar lines of code.

Inside each section that is called by run you can use the respective parameters which are numbered from #1 to #9

This means that you can use a Run,%scriptfile%,mysection,"Hello World!"
And inside the [mysection] of the same script you can use a command like echo,#1 to display "Hello World!" on your log.
WB078 added: If a 'Run' has more than 9 parameters, they can be accessed by two new commands:

GetParam,Index,%Var
% writes parameter #index into %var%
PackParam,Start,%Var% packs all parameters beginning with <start> into %var%, each enclosed in quotes, and separated by comma, like: "param4","param5",...


PackParam optionally has an additional argument.
PackParam,Start,%Var%,%Num%. It writes the number of arguments into %Num%.
%Num% is always the number of
ALL arguments, independent from Start The parameters can be declared as "OUT" variables, that means when returning from "Run", they will be updated with the actual value.

Syntax example: Run,%scriptfile%,mySection,%first%,OUT:%second%,%third%
After returning from the "Run", %first% and %third% are unchanged, regardless whether inside the "Run" #1 and / or #3 are changed.

%second% will get the actual value of #2 when "Run" is finished.

Exec   This command has a very similar behavior to the one described by the run command. It will additionally add all the variables found inside the [variables] section. Identical variables found on the new script will overwrite the older ones.

The "OUT" mechanism is not supported by EXEC.


ShellExecute / ShellExecuteEx / ShellExecuteDelete


ShellExecute,<Action>,<Filename>[,Parameters][,StartDir]
ShellExecuteEx,<Action>,<Filename>[,Parameters][,StartDir]
This function will launch a file using the settings you specify. Action is the specific method you wish to use to start the external file. By default "Open" is the most used one. Possible action values


Filename is the complete filename to where the file can be found, you can omit the dir part if this file can be found on the system paths.


Parameters (optional) are the set of switches that you can pass along as command line parameters when executing the file.

StartDir (optional) is the location that you wish to specify as your default work directory.


The script will wait (pause) for the launched file or application to be closed before continuing processing the remaining commands.


ShellExecuteDelete - has a similar behavior but will delete the application after it has been finished.

ShellExecuteEx - has a similar behavior but won't wait for the application to be finished and will continue with the script processing right after launching the target filename.

Syntax example: ShellExecute,open,cmd.exe In this example we can open a new console window (cmd.exe)

Beep


Beep,<Action> This is a very simple command that will use the default sound profile used on your machine to beep messages that requires the attention of the user.

Action can be one of the following values

Syntax example: beep,ok

Message


Message,<message>,<Action> This command will pop a small text window displaying the contents of your message. The additional action parameter will allow you to customize the icon displayed along with the message box.

Action can have of the following values

Syntax example: message,"Script has been completed!",Information
WB076 added:
Usually the message dialog waits for ever for the user's ok.
You can cause to close it after a timeout, by adding the timeout (in seconds) as last argument.
message,"Script has been completed!",Information,10

System


System,<Action> This command is used to perform some program internal actions and refresh values that were modified during the script execution. It will set a flag that reminds the program to perform the specified action once the project is completed.
Action can have of the following values


WB076 added:




System,FILEREDIRECT
System,FILEREDIRECT,{ON|OFF}

Syntax example: System,FILEREDIRECT,OFF
ShellExecute,Hide,"cmd.exe","/c imdisk -d -m %FreeLetter%"
System,FILEREDIRECT,ON

Maybe necessary when WinBuilder is running on a 64bit system. Some directory calls are getting redirected by the OS  to avoid possible conflicts.

Using a 32bit system this command is without effect.

 


System,REGREDIRECT
System,REGREDIRECT,{64|32|OFF}

Syntax example:
System,REGREDIRECT,64
RegRead,HKLM,”SOFTWARE\Sun\xVM VirtualBox",InstallDir,%VBPath%
System,REGREDIRECT,OFF

Maybe necessary when WinBuilder is running on a 64bit system. Some registry calls are getting redirected by the OS to avoid possible conflicts.

Every definition is valid from "now" to "ever"

Using a 32bit system this command is without effect.

 


System,GetFreeSpace
System,GETFREESPACE,<Path>,<%var%>
Returns the free space of Path's drive in megabytes
(megaybtes = free bytes / 1024 / 1024)


Syntax example:
System,GETFREESPACE,%BaseDir%,%var%
System,GETFREESPACE,C:,%var%
System,GETFREESPACE,C,%var%
Result:
%var% indicates the free space of %BaseDir% or of “C:”

 


System,GetFreeDrive
System,GetFreeDrive,<%var%>
This command returns the highest available free drive letter, mostly “Z:”

 


System,ERROROFF
System,ERROROFF[,lines]
This command causes that a script processing error is not marked as error and therefore the program continues.

By default this functionality is valid for the next script line. That can be changed by defining the optional number of lines.

Syntax example:
System,ERROROFF
RegRead,HKLM,"CurrentControlSet\Services\Eventlog\Application\VMware Virtual Mount Service Extended",EventMessageFile,%VMtmp%
If,NOT,EXISTVAR,%VMtmp%,Begin
System,ERROROFF,2
RegRead,HKCR,Wow6432Node\Applications\vmware-mount.exe\shell\Mount\command,,%VMtmp%
If,NOT,EXISTVAR,%VMtmp%,RegRead,HKCR,Applications\vmware-mount.exe\shell\Mount\command,,%VMtmp%


System,ONSCRIPTEXIT
System,ONSCRIPTEXIT,<Command>
This statement can be written anywhere inside the running part of a script.

It will be executed after the last script's statement has been executed.

If command is 'Run' as parameter #1 the 'type' of the exit is passed

Syntax example:
System,ONSCRIPTEXIT,Message,"Everything Done!",INFORMATION

Syntax example:
System,ONSCRIPTEXIT,Run,%ScriptFile%,MYEXIT
// force an error:
FileCopy,y,x

[MYEXIT]
If,#1,EQUAL,ERROR,Beep,ERROR
If,#1,EQUAL,STOP,Beep,WARNING
If,#1,EQUAL,DONE,Beep,OK
If,#1,EQUAL,COMMAND,Beep,CONFIRMATION

 


System,ONBUILDEXIT
System,ONBuildEXIT,Command
This statement can be written anywhere inside the running part of a script.
Always the last executed statement is valid.
So different scripts can define different actions or deactivate with System,ONBUILDEXIT
It will be executed after the last script in the project has been processed.
More examples in System,ONSCRIPTEXIT

 


System,REBUILDVARS
This is a successor of System,RefreshVars, which since WB076 in most cases is not more necessary.

Syntax example: Set,%First%,first
Set,%Result%,"Here is %first%"
Echo,Value of #$pResult#$p is: %Result%
// >> Here is first
Set,%First%,second
Echo,Value of #$pResult#$p is: %Result%
//  >> Here is first
System,RebuildVars
Echo,Value of #$pResult#$p is: %Result%
// >> Here is second

 


System,GETENV
System,GETENV,<EnvironmentVariable>,%var%
<EnvironmentVariable> must not be enclosed in percent!

Syntax example:
System,GETENV,Temp,%var%
Echo,%var%



System,ISADMIN
System,ISADMIN,%var%
Sets %var% to True or False, depending on whether WinBuilder has been started by an admin.

 


System,Cursor
System,CURSOR,{WAIT|NORMAL}
Sets  the system cursor as hourglass or the default cursor.

 


System,SAVELOG
System,SAVELOG,<OutputFile>
Saves the actual accumulated log to <OutputFile>. <OutputFile> should have the extention '.html'.
Usefull for debugginp purposes:
When a build reproducable hangs in a certain script, you can save the log before or in the beginning of this script.



System,SPLITPARAMETERS
System,SPLITPARAMETERS,{ON|OFF}
Splits in a 'Run' or 'Exec' command a single parameter which contains commas, into severel parameters.

The System,SPLITPARAMETERS,ON command can be given once in the project, e.g. in [Process] of script.project, and is then valid for the complete project (or until it is switched off by System,SPLITPARAMETERS,OFF, and then switched on again, and ....)
Syntax example: [process]
Set,%List%,"a,b,c"
Run,%ScriptFile%,Test,%List%
System,SPLITPARAMETERS,ON
Run,%ScriptFile%,Test,%List%
System,SPLITPARAMETERS,OFF

[Test]
Echo,#1
Echo,#2
Echo,#3
Log result:
Processing section: [process]
File [%BaseDir%\Projects\win7_pe\CodeBox.txt] Version [1]

SetVar - Sucessfuly changed the value of [%List%] to: [a#$cb#$cc]
Run - Processing section: [Test] From file: [%BaseDir%\Projects\win7_pe\CodeBox.txt]
with parameters: [a,b,c]
a,b,c


Run - Processed section [Test] in file: [%BaseDir%\Projects\win7_pe\CodeBox.txt]
System,SplitParameters,ON
Run - Processing section: [Test] From file: [%BaseDir%\Projects\win7_pe\CodeBox.txt]
with parameters: [a],[b],[c]
a
b
c
Run - Processed section [Test] in file: [%BaseDir%\Projects\win7_pe\CodeBox.txt]
System,SplitParameters,OFF

 

Echo


echo,<message>
This is a very simple command that will output your message to the processing window while the script is running. This message will only disappear until another message is displayed or the script finishes. These messages are also stored in the log and are used to inform the user about operations being performed by the script.

Syntax example: echo,"Hello World!"


Wait


wait[,seconds]
Using this command will pause the script processing the value of seconds that you specify. After this period is concluded, the process will continue.

Syntax example: wait,5 This example will make the application wait 5 seconds before continuing


Exit


Exit,<exit message>
This command will force the script to be finished and will make the process continue to the next script on the list.

Exit message is a small text message that is displayed on the log where you can specify the reason why Exit was called.

Syntax example: Exit,"File was not found"

Halt


Halt,<reason>
This command will force the overall project to terminate.

Reason is a small text message that is displayed in the log where you can specify the reason why Halt was called.

Syntax example: Halt,"Incompatible Source"

SET


Set,<%Variable%>,<NewValue>
With this command we can change the value of a variable

If more variables are linked to this variable, then you might need to call

System,RefreshVars to ensure that all variables get refreshed values and work properly. Syntax example: Set,%workdir%,c:\myPath


WB076 added:

A new variable handling makes System,RefreshVars unnecessary. Usually the variables definition has a lifetime of the current script.

You can make it valid for the rest of the actual Build by adding a ',GLOBAL' and valid for ever (write into script.projects) by adding a ',PERMANENT.

AddVariables


AddVariables,<%ScriptFile%>,<Section>
Use this command to add more variables to the script based on the entries found inside another section from any script file.
When a script is started it will read the [variables] section, during the script processing you can repeat this procedure and read the variables found inside any section you wish to use.

Use %scriptfile% to read a section from the same file from where this command is called.

Older variables with the same designation are overwritten with newer values.

Syntax example: AddVariables,%scriptFile%,AlternativeVariables

WB076 added: There is an additional optional parameter possible:
GLOBAL: If this parameter is set, the additional variables will be known through the complete build.
 

Loop


Loop,%ScriptFile%,<Section>,<start>,<end>
Section in %Scripfile% is repeatedly executed with a counter between start and end value. The loop can be prematurely exited by Loop,BREAK

Syntax example: Set,%Result%,?
Loop,%ScriptFile%,Try-OEM,0,100,SourceDisksFiles,VBoxUSB.sys
Echo,%Result%

[Try-OEM]
Set,%file%,C:\Windows\inf\oem#c.inf
If,ExistFile,%file%,IniRead,%file%,#1,#2,%Var%
If,-%var%,NotEqual,-,Set,%Result%,%file%
If,%Result%,NotEqual,?,Loop,BREAK
This code is searching in all oem.inf files in path C:\Windows\inf (oem0.inf up to oem100.inf) for entry VBoxUSB.sys in section [SourceDisksFiles].
If it’s found the oem.inf file name is set as result and the loop ends.
NOTE:
oem.inf files are always beginning with ZERO (=oem0.inf)!

Loop statement can run between characters, e.g. drive letters

Syntax example:
Set,%a_searchFile%,”Program Files\IrfanView\i_view32.exe”
Loop,%ScriptFile%,Try,a,z
If,EXISTFILE,%pstart%,ShellExecute,OPEN,%pstart%

[try]
Set,%pstart%,#c:\%a_searchFile%
If,EXISTFILE,%pstart%,Loop,BREAK
In this example the Loop statement is looking for the EXE-file on all drive letters from A: to Z:.
If the EXE-file is found it will be executed.

 

Command Blocks

If the evaluation of an If condition is 'True', the command following the condition is processed. If the evaluation of an If condition is 'False', the command of the Else command (if present), is processed.
In both cases, instead of a command, there can also be a command block.
Begin
  <command>
  <command>
  ...   <command>
End
<command>  can be any valid script command.
Because <command> can also be an If, nested command blocks are possible.

Syntax example:
If,%OSName%,Equal,xp,Begin
  If,%SP%,NotEqual,sp3,Begin
    If,%pCheckBox1%,Equal,True,Run,%ScriptFile%,Process-KB893803
  End
  Else,Begin
    Set,%hotfix%,1
    Run,%ScriptFile%,Process-Copy
  End
End
Else,...

Bugs

When a command doesn't work as expected you should follow these steps to ensure that it is a true bug and not a human error:


If none of the above solves your issue then here's the recommended way to proceed:

 

Log of changes

Changes in script language can be followed in each newer WinBuilder beta discussion where changes to the script code are suggested and debugged by other members. 

Projects also follow their own script rules and these methods can change occasionally, whenever in doubt you should post your questions in each project forum discussion.

Please let us know if this page is not complete or if you still haven't found needed information.