Previous article
Next article

4.3.2 Script-based installation for version 30 SP2024

Here is an example of a simple batch file to install Version 30 SP2024 from an existing update folder without checking the already installed version, . This update folder can be supplied by the offline setup: With catalogs, cadworkprofil and userprofil.

In the script below, for some modules, the presence in the folder is not checked. The reason is that their installation is mandatory and the executables will be automatically downloaded during a standard update and are present in the offline setup.

@ECHO off 
:: Force UTF-8 encoding for output (Windows 10+)
chcp 65001

:: Variable definitions
:: Date and time definition
SET year=%DATE:~6,4%
SET month=%DATE:~3,2%
SET day=%DATE:~0,2%
SET hour=%TIME:~0,2%
IF "%hour:~0,1%"==" " SET hour=0%hour:~1,1%
SET minutes=%TIME:~3,2%

:: Repetitive messages
SET installModulesFinished=Installation finished
SET exeFileNotFound=Executable file not found

:: cadwork variable definitions
:: Both the client number and the language are essential for installation.
:: An incorrect number will cause installation or license errors.
:: The chosen language will affect the catalogs to be installed.
:: Contact cadwork support if needed.

SET update=FALSE
SET remove=FALSE
SET version=30.0
SET clientNumber=04.12345.0
SET language=english

:: cadwork installation directory. It should never be changed without consulting cadwork support.
SET cadworkDir=%programfiles%\cadwork.dir

:: Network paths must be in UNC format.
:: Define a base for folder paths
SET basePath=D:\cadwork
SET updateDir=%basePath%\update
SET userprofileDir=%basePath%\userprofil_%version%
SET userCatalogDir=%basePath%\cadwork.cat
SET installLogDir=%basePath%\logs-dir

:: Create folders if they do not exist
IF NOT EXIST "%updateDir%" (
    MKDIR "%updateDir%"
)
IF NOT EXIST "%userprofileDir%" (
    MKDIR "%userprofileDir%"
)
IF NOT EXIST "%userCatalogDir%" (
    MKDIR "%userCatalogDir%"
)
IF NOT EXIST "%installLogDir%" (
    MKDIR "%installLogDir%"
)


:: Define the log file with date and time in the desired format
SET logFile=%installLogDir%\%year%_%month%_%day%_%hour%_%minutes%.txt


:: Call the main script "main" and redirect standard and error outputs
:: to the log file.
CALL :main > "%logFile%" 2>&1


:: End of script
PAUSE
ECHO %installModulesFinished%. We wish you a pleasant use.
GOTO :EOF


:: Uninstallation
if %remove%==TRUE goto :REMOVE


:main
ECHO %DATE% - %hour%:%minutes% - SCRIPT START

:: Module installation (First installation and update)
:: Program section
:: At the root of the cadworkDir folder
:: Ci-Start program
IF EXIST "%updateDir%\EXE\cadwork_CI-Start_%version%_x64.exe" (
	"%updateDir%\EXE\cadwork_CI-Start_%version%_x64.exe" /dir="%cadworkDir%" /verysilent
	ECHO ci_start - %installModulesFinished%
) ELSE (
	ECHO The installer for Ci-Start, a mandatory component, is missing
)

:: Ci-Com module
IF EXIST "%updateDir%\EXE\cadwork_CI-COM_%version%_x64.exe" (
	"%updateDir%\EXE\cadwork_CI-COM_%version%_x64.exe" /dir="%cadworkDir%" /verysilent
	ECHO Ci-Com - %installModulesFinished%
) ELSE (
	ECHO Ci-Com - %exeFileNotFound%
)

:: Subfolder by cadwork version
:: 2D module
IF EXIST "%updateDir%\EXE\cadwork_2D_%version%_x64.exe" (
	"%updateDir%\EXE\cadwork_2D_%version%_x64.exe" /dir="%cadworkDir%\EXE_%version%" /verysilent
	ECHO 2D - %installModulesFinished%
) ELSE (
	ECHO 2D module - %exeFileNotFound%
)

:: 2DV module
IF EXIST "%updateDir%\EXE\cadwork_2DV_%version%_x64.exe" (
	"%updateDir%\EXE\cadwork_2DV_%version%_x64.exe" /dir="%cadworkDir%\EXE_%version%" /verysilent
	ECHO 2DV - %installModulesFinished%
) ELSE (
	ECHO 2DV module - %exeFileNotFound%
)

:: 3D module
IF EXIST "%updateDir%\EXE\cadwork_3D_%version%_x64.exe" (
	"%updateDir%\EXE\cadwork_3D_%version%_x64.exe" /dir="%cadworkDir%\EXE_%version%" /verysilent
	ECHO 3D - %installModulesFinished%
) ELSE (
	ECHO 3D module - %exeFileNotFound%
)

:: Database module (3D textures and metal profiles)
IF EXIST "%updateDir%\EXE\cadwork_Database_%version%.exe" (
	"%updateDir%\EXE\cadwork_Database_%version%.exe" /dir="%cadworkDir%\EXE_%version%" /verysilent
	ECHO Database module - %installModulesFinished%
) ELSE (
	ECHO Database module - %exeFileNotFound%
)

:: Cadwork Concept module (also called Lexocad)
IF EXIST "%updateDir%\EXE\cadwork_Lexocad_%version%_x64.exe" (
	"%updateDir%\EXE\cadwork_Lexocad_%version%_x64.exe" /dir="%cadworkDir%\EXE_%version%" /verysilent
	ECHO Cadwork Concept module - %installModulesFinished%
) ELSE (
	ECHO Cadwork Concept module - %exeFileNotFound%
)

:: List module
IF EXIST "%updateDir%\EXE\cadwork_List_%version%_x64.exe" (
	"%updateDir%\EXE\cadwork_List_%version%_x64.exe" /dir="%cadworkDir%\EXE_%version%" /verysilent
	ECHO List module - %installModulesFinished%
) ELSE (
	ECHO List module - %exeFileNotFound%
)

:: LxSDK module (Some mandatory libraries)
IF EXIST "%updateDir%\EXE\cadwork_LxSDK_%version%_x64.exe" (
	"%updateDir%\EXE\cadwork_LxSDK_%version%_x64.exe" /dir="%cadworkDir%\EXE_%version%" /verysilent
	ECHO LxSDK module - %installModulesFinished%
) ELSE (
	ECHO LxSDK module - %exeFileNotFound% - Mandatory libraries for 3D are missing
)

:: Pclib module (Libraries common to all modules)
IF EXIST "%updateDir%\EXE\cadwork_Pclib_%version%_x64.exe" (
	"%updateDir%\EXE\cadwork_Pclib_%version%_x64.exe" /dir="%cadworkDir%\EXE_%version%" /verysilent
	ECHO Pclib module - %installModulesFinished%
) ELSE (
	ECHO Pclib module - %exeFileNotFound% - Mandatory libraries for all modules are missing
)

:: OptiPanel module
IF EXIST "%updateDir%\EXE\cadwork_OptiPanel_%version%_x64.exe" (
	"%updateDir%\EXE\cadwork_OptiPanel_%version%_x64.exe" /dir="%cadworkDir%\EXE_%version%" /verysilent
	ECHO OptiPanel - %installModulesFinished%
) ELSE (
	ECHO List module - %exeFileNotFound%
)


:: Subfolder by cadwork version - Subfolder "PI" - License-dependent module.
:: Lamel module (For glulam manufacturers)
:: This module may not be present as it depends on the client number.
IF EXIST "%updateDir%\EXE\cadwork_Lamel_%version%_x64.exe" (
	"%updateDir%\EXE\cadwork_Lamel_%version%_x64.exe" /dir="%cadworkDir%\EXE_%version%" /verysilent
	ECHO Lamel - %installModulesFinished%
) ELSE (
	ECHO Lamel - %exeFileNotFound%
)


:: cadwork catalogs and cadworkprofil (First installation and update)
:: According to fixed folder defined by cadwork (cannot be changed by the user)
:: Architecture catalogs
IF EXIST "%updateDir%\CAT\%language%\architecture_%language%_%clientNumber:~0,2%_%version%.exe" (
	"%updateDir%\CAT\%language%\architecture_%language%_%clientNumber:~0,2%_%version%.exe" /verysilent
	ECHO Architecture catalogs - %installModulesFinished%
) ELSE (
	ECHO Architecture catalogs - %exeFileNotFound%
)

:: Plugins created by Cadwork (cadworkprofil)
IF EXIST "%updateDir%\CAT\%language%\cadworkprofil_%language%_%clientNumber:~0,2%_%version%.exe" (
	"%updateDir%\CAT\%language%\cadworkprofil_%language%_%clientNumber:~0,2%_%version%.exe" /verysilent
	ECHO Cadworkprofil - %installModulesFinished%
) ELSE (
	ECHO Cadworkprofil - %exeFileNotFound%
)

	:: 2D catalogs
IF EXIST "%updateDir%\CAT\%language%\catalog_2d_%language%_%clientNumber:~0,2%_%version%.exe" (
	"%updateDir%\CAT\%language%\catalog_2d_%language%_%clientNumber:~0,2%_%version%.exe" /verysilent
	ECHO 2D catalogs - %installModulesFinished%
) ELSE (
	ECHO 2D catalogs - %exeFileNotFound%
)

:: 3D catalogs
IF EXIST "%updateDir%\CAT\%language%\catalog_3d_%language%_%clientNumber:~0,2%_%version%.exe" (
	"%updateDir%\CAT\%language%\catalog_3d_%language%_%clientNumber:~0,2%_%version%.exe" /verysilent
	ECHO 3D catalogs - %installModulesFinished%
) ELSE (
	ECHO 3D catalogs - %exeFileNotFound%
)

:: cadwork manuals
IF EXIST "%updateDir%\CAT\%language%\manual_%language%_%clientNumber:~0,2%_%version%.exe" (
	"%updateDir%\CAT\%language%\manual_%language%_%clientNumber:~0,2%_%version%.exe" /verysilent
	ECHO cadwork manuals - %installModulesFinished%
) ELSE (
	ECHO cadwork manuals - %exeFileNotFound%
)

:: Version news
IF EXIST "%updateDir%\CAT\%language%\news_%language%_%clientNumber:~0,2%_%version%.exe" (
	"%updateDir%\CAT\%language%\news_%language%_%clientNumber:~0,2%_%version%.exe" /verysilent
	ECHO News - %installModulesFinished%
) ELSE (
	ECHO News - %exeFileNotFound%
)

:: Variant catalogs (parametric catalog files)
IF EXIST "%updateDir%\CAT\%language%\variant_%language%_%clientNumber:~0,2%_%version%.exe" (
	"%updateDir%\CAT\%language%\variant_%language%_%clientNumber:~0,2%_%version%.exe" /verysilent
	ECHO Variant catalogs - %installModulesFinished%
) ELSE (
	ECHO Variant catalogs - %exeFileNotFound%
)

:: Video catalogs (links to training videos on YouTube, Vimeo or other online platforms)
IF EXIST "%updateDir%\CAT\%language%\videos_%language%_%clientNumber:~0,2%_%version%.exe" (
	"%updateDir%\CAT\%language%\videos_%language%_%clientNumber:~0,2%_%version%.exe" /verysilent
	ECHO Video catalogs - %installModulesFinished%
) ELSE (
	ECHO Video catalogs - %exeFileNotFound%
)


:: Userprofil (here on the network and should not be installed by each client)
IF EXIST "%userprofileDir%" (
	ECHO userprofil already installed
) ELSE (
	"%updateDir%\CAT\%language%\userprofil_%language%_%clientNumber:~0,2%_%version%.exe" /dir="%userprofileDir%" /verysilent
	ECHO Userprofil - %installModulesFinished%
)
ECHO %installModulesFinished%

ECHO END OF SCRIPT
PAUSE
:: Installation ends here.

:: This batch is not intended for an update.
:: Therefore, if the update variable is set to "TRUE", nothing will happen
IF %update%==TRUE GOTO :EOF


:: For the first installation:
:: - Save the client number
ECHO %clientNumber% > "%cadworkDir%\CLIENT_NR.TXT"

:: - VCRedist is mandatory, DirectX 9c may need to be installed manually
"%cadworkDir%\exe_%version%\pclib.x64\redist\vcredist_x64\vcredist2015-2022_x64.exe" /install /quiet /norestart

:: - Create shortcuts and registry entries via cadwork start
"%cadworkDir%\ci_start.exe" /INSTALL /SILENT /USP="%userprofileDir%" /CATDIR="%userCatalogDir%" /DownloadDir="%updateDir%" /USER_HOLZ
IF NOT EXIST "%PROGRAMDATA%\Firebird\" MKDIR "%PROGRAMDATA%\Firebird"


PAUSE
GOTO :EOF


:: Remove a local installation
:: - updateDir, userprofileDir and userCatalogDir are on the network and are therefore not deleted here
:REMOVE
IF EXIST "%cadworkDir%\ci_start.exe" "%cadworkDir%\ci_start.exe" /UNINSTALL /SILENT
IF EXIST "%cadworkDir%\" RMDIR /s /q "%cadworkDir%"
IF EXIST "%PROGRAMDATA%\cadwork\" RMDIR /s /q "%PROGRAMDATA%\cadwork"
IF EXIST "%PROGRAMDATA%\Firebird\" RMDIR /s /q "%PROGRAMDATA%\Firebird"
IF EXIST "%PUBLIC%\documents\cadwork\" RMDIR /s /q "%PUBLIC%\documents\cadwork"
IF EXIST "%APPDATA%\cadwork\" RMDIR /s /q "%APPDATA%\cadwork"
Pause