For creating flexible installations, you can use commands to be executed on the user's computer. You can run any Windows commands, PowerShell scripts, launch files with command-line parameters, and more.
To add a command, go to the System \ Commands tab and click Add.
File: Specify a file to run or a URL to open.
Examples:
C:\Windows\notepad.exe
<InstallDir>\Updater.exe
https://www.example.com
Parameters: (optional) Specify command line parameters (flags) for the file.
Launch on OS: Specify the 32-bit, 64-bit or Any Windows platform on which the command should run. Commands can also be run on specific Windows versions (see below).
Show: The window state: Normal or Hidden
Timing: Specify when the command should be run:
NOTE: Do not use files from folder <InstallDir> with timings Before Installation, At User Information dialog, and At Folder Select dialog, Click Install because they are not created yet. To be able to run that files, they have to be located in the <SetupTempDir> folder (a temporary directory of the installation). All files added in <SetupTempDir> folder are available right after starting the setup program.
Wait for process to finish: The setup program waits for the process to terminate before continuing. When using this option the setup program will store the exit code of the command in the variable <ExitCode> . And you can use this variable to perform an additional task by adding a new command.
Run as admin: The file will be launched with administrator privileges.
NOTE: You don't have to select this option if you already selected the option "Run as Administrator" on the General \ Parameters page. In this case, the setup program will be launched with administrative privileges and all commands will inherit admin privileges automatically. If you configured your setup to install for All Users, then the setup program will have administrator rights (for Classic Wizard always; for Modern Interface ONLY during performing the main installation tasks - copying files, modifying Registry, executing commands After Installation).
Run Test.exe file (from the app install directory) after installation:
File: <InstallDir>\Test.exe Parameters: Timing: After Installation
Run Check.exe file (from the setup temp directory) with a parameter /S, before installation:
File: <SetupTempDir>\Check.exe Parameters: /S Timing: Before Installation
Open website after installation:
File: https://www.example.com Parameters: Timing: After Installation
Also, it is possible to run any Windows commands by using the command interpreter cmd.exe which is located in the system directory of Windows: C:\Windows\System32 .
This allows you to launch files, tasks, scripts, batch files (BAT files), run commands based on conditions, start and stop services, and much more.
To run a command you need to launch the cmd.exe file with specific command-line parameters which should begin with /C (runs the specified command-line and then exits). To see the result of the command it should begin with /K. For more information, click here.
For example:
To create an empty folder you need to execute:
C:\Windows\System32\cmd.exe /C mkdir "C:\New Folder"
or just: cmd.exe /C mkdir "C:\New Folder"
In Actual Installer project, you need to specify this as:
File: <SystemDir>\cmd.exe Parameters: /C mkdir "C:\New Folder" Launch on OS: Any Show: Normal or Hide Timing: After Installation, or any other Wait: No Run as admin: No
IMPORTANT: In the Parameters field, all file / folder paths containing spaces must be quoted.
NOTE: <SystemDir> is an installer variable that contains the path to the System directory.
NOTE: Do not forget to add /C or /K at the beginning in the Parameters.
Create an empty folder:
mkdir "C:\New Folder"
Delete a file:
del /Q "<InstallDir>\file.exe"
Delete a folder with all files and subfolders:
rmdir /S /Q "C:\Folder"
Copy a file from SetupTempDir to InstallDir:
copy /y "<SetupTempDir>\File.exe" "<InstallDir>\File.exe"
Copy folder with all files and subdirectories from SetupTempDir to InstallDir:
xcopy "<SetupTempDir>\Folder" "<InstallDir>\Folder" /E /Y
Change the folder attribute to 'Hide':
attrib +H "<InstallDir>\Folder"
Close / terminate Notepad:
taskkill /F /IM notepad.exe /T
Install MSI package:
msiexec /i "<InstallDir>\File.msi"
Set Current Directory to Installation Directory:
CD /D "<InstallDir>"
Set Current Directory to Installation Directory and launch a file:
(CD /D "<InstallDir>") && (START File.exe)
Check if the file exists and then rename / move it:
IF EXIST "C:\File.exe" ( MOVE /Y "C:\File.exe" "C:\NewFile.exe")
Check if two conditions are true, and copy file:
IF EXIST "C:\File.exe" (IF NOT EXIST "C:\NewFile.exe" (COPY /Y "C:\File.exe" "C:\NewFile.exe"))
Delete registry key:
reg delete /f "HKEY_LOCAL_MACHINE\SOFTWARE\MyAppKey"
Import registry keys from a .REG file:
regedit /S "<InstallDir>\file.reg"
Launch a file on Windows 7 only:
IF /I <WindowsVersion>==6.1 "<InstallDir>\File.exe"
Variable <WindowsVersion> contains Windows version number: 5.2 = Windows XP or Windows Server 2003 6.0 = Windows Vista or Windows Server 2008 6.1 = Windows 7 or Windows Server 2008 R2 6.2 = Windows 8 or Windows Server 2012 6.3 = Windows 8.1 or Windows Server 2012 R2 10.0 = Windows 10 or Windows 11 or Windows Server 2016 and newer == means Equal. Compares strings. More info at http://ss64.com/nt/if.html
Run a command (copy a file from SetupTempDir to InstallDir) only on Windows Vista and newer versions:
IF <WindowsVersion> GEQ 6 (COPY /Y "<SetupTempDir>\File.exe" "<InstallDir>\File.exe")
GEQ means Greater than or equal.
Run a batch (.BAT) file and check its exit code ( or %ERRORLEVEL%) in the installer:
To make it, we need two commands:
1. Add a command to run .bat file:
File: <InstallDir>\run.bat Parameters: Wait: YES
Now the variable <ExitCode> contains an exit code of the batch file.
2. Check if it is 5, and show a message to the user:
File: IF <ExitCode>=5 Parameters: MSG(your_messagge) Wait: NO
Get some text result of a batch (.BAT) file or a command, and use it in the installer:
In the batch script or command save the result in the temp folder, for example: "%tmp%\result.txt" using the operator > "%tmp%\result.txt"
1. Launch .BAT file with the WAIT flag:
File: <InstallDir>\run.bat Parameters: Wait: YES
2. run a special command GETVARIABLES (see below), as Variables are read before executing Commands:
File: GETVARIABLES Parameters:
3. Read the text result from the temp file "%tmp%\result.txt" to a variable using System / Varibles:
Variable Name <Result> Bitness Default Registry Key <TempDir>\result.txt Registry Value Value Type STRING Default Data
Variable <Result> will contain an output of the batch script.
Open File Explorer with a specific file selected
File: <WindowsDir>\explorer.exe Parameters: /select,"C:\MyDir\MyApp.exe"
Create an empty folder using PowerShell:
File: PowerShell.exe Parameters: New-Item -Path 'C:\New Folder' -ItemType Directory or Parameters: -Command New-Item -Path 'C:\New Folder' -ItemType Directory
IMPORTANT: In PowerShell, in the Parameters field, paths containing spaces must be enclosed in single quotes.
NOTE: To see the result in PowerShell, the parameters must begin with -NoExitCall specific function from DLL file using rundll32.exe: for example, open the "About Windows" dialog box:
File: rundll32.exe Parameters: shell32.dll,ShellAbout
Format: "C:\path-to-your.dll",FunctionName [arguments]
File: CMDVAR Parameters: specify a file
File: DOWNLOAD:URL Parameters: specify where to save the file
Example: File: DOWNLOAD:http://www.example.com/file.txt Parameters: C:\file.txt
If the "Wait" option is checked, then the variable <ExitCode> will contain 0 (success download) or 1 (download failed).
If the "Show" option is set to "Hide", then do not show text "Downloading".
Available setup parameters:
-ShowDownloadURL add this parameter to show the download URL (for Classic Interface only, and Timing "After Installation")
-ErrorIfDwnFail if the download fails, then show "Installation completed with errors" on the finish dialog
-HaltIfDwnFail if the download fails, then halt the installation
-UserAgent use the following User Agent string: Mozilla/5.0 (compatible; AppNameSetup/AppVersion). Default is: setup file name (for example, Setup.exe)
File: ZIP:specify .ZIP file Parameters: Specify a folder where to extract files Example: File: ZIP:C:\Archive.zip Parameters: C:\MyFolder
File: SetCurrentDir Parameters: specify a directory
Custom Variables are read when the setup program is launched (at setup startup). Then the setup program runs Commands. If you need to read Custom Variables again, add:
File: GETVARIABLES Parameters: leave empty
If your app is 32-bit and you install it on 64-bit Windows, then when trying to access files in "C:\Windows\System32" it will be automatically redirected to "C:\Windows\SysWOW64" by WOW64 System. To access the "real C:\Windows\System32" you may use the path "<WindowsDir>\sysnative" or you can disable the WOW64 redirection using the Commands.
Disable WOW64: add a new command and in the File field type WOW64OFF
Enable WOW64: in the File field type WOW64ON
The Parameters field leave empty.
Caution: Always turn on the WOW64 after it was disabled and the main command is finished (set Wait to 'Yes')! Otherwise other file operations may fail.
First add a command WOW64OFF, then add a command for the operation in System32, and finally add a command WOW64ON to turn it back.
File: MSG Parameters: your message, for new line use <#>
File: IFMSG(message)
File: IFMSG(message)[specify Windows versions in which to show a message, e.g. 7,10]
Parameters: enter command or URL, for example: <InstallDir>\File.exe
Example: conditions in Parameters:
Parameters: <SystemDir>\cmd.exe /C if <ExitCode>==1 ("<InstallDir>\File.exe")
If you want to launch a file (or copy, move, or other file operation.) with condition then use the following format:
File: <SystemDir>\cmd.exe Parameters: /C IF /I <var1>==<var2> command
Examples:
If setup language is French then launch File.exe:
Parameters: /C IF /I <Language>==French "<InstallDir>\File.exe"
If language is French then copy file "French.lng" from SetupTempDir to Installation Directory:
Parameters: /C IF /I <Language>==French (COPY /Y "<SetupTempDir>\French.lng" "<InstallDir>\French.lng")
If language is French then download a file "French.pdf" to the Installation Directory:
First, add Downloader (select the menu "Tools / Add Downloader")
Parameters: /C IF /I <Language>==French ("<SetupTempDir>\Downloader.exe /S "http://www.website.com/French.pdf" /D "<InstallDir>\French.pdf")
More information about "IF" command http://ss64.com/nt/if.html
If you want to show a message, stop the current action, or halt the installation, use the following format:
File: IF <var1>=<var2> File: IF <var1>!=<var2> File: IF <var1>><var2> File: IF <var1><<var2> to show a message: Parameters: MSG(your message)
to terminate the installation with a message: Parameters: HALT(your message)
to terminate the installation without messaging: Parameters: HALT()
to stop the current action (only for Timing "Click Install", "At User Information dialog", and "At Folder Select dialog"): Parameters: STOP(your message)
do not run remaining commands Parameters: EXIT
to show a message with YES & NO buttons, and run a command if the User clicks YES: Parameters: IFMSG(your message)command
Note: To compare strings, add quotes. Without quotes, specified values are compared as numbers or versions (example: 2=2.0 is true; "2"="2.0" is false).
Examples:
If you want to check an exit code of the command and then show a message. Previous command must be launched with flag "Wait" checked.
File: IF <ExitCode>=1 Parameters: MSG(your message)
To check if a variable is empty:
File: IF <var1>="" Parameters: MSG(your message)
Functions to extract file name or directory from a path are described here.
Set Full Control security permissions to a folder
You can use the following parameters in the Setup Parameters:
-nocmdifsilent - commands will not be executed in the Silent mode
-nocmdifupdate - commands will not be executed in the Update mode
If you have any questions, please contact us.