I am stucked while trying to launch Dos commands in the setup.ins script in order to create a folder in C:\Users\User\AppData\Roaming.
I have tried using cd %AppdataDir% and cd %CurrentAppdataDir% to enter inside the Roaming folder but it does not work, nor using the full path (cd C:\Users\User\AppData\Roaming). I have used the "mkdir" command to try to create the folder 'Spark' inside the Roaming folder, but impossible.
It seems OPSI does not recognize my variables nor my DOS commands, but I have added the [DOSInAnIcon_1] section in my script (in [actions] section):
[Actions]
DOSInAnIcon_1 winst /32Bit
[DOSInAnIcon_1]
@echo off
cd %AppDataDir%\
mkdir Spark
Also impossible to copy the spark.properties file inside a "AppData\Roaming\" folder while using the usual command copy -s "%Scriptpath%\spark.properties" "%AppDataDir%\Spark\" . And I am in the good section in my script: [Files_install] (which is usually called by OPSI).
Here is my script:
; Copyright (c) uib gmbh (http://www.uib.de)
; This sourcecode is owned by uib
; and published under the Terms of the General Public License.
; credits: http://www.opsi.org/en/credits/
[Actions]
requiredWinstVersion >= "4.11.2.6"
DefVar $MsiId$
DefVar $UninstallProgram$
DefVar $LogDir$
DefVar $ProductId$
DefVar $MinimumSpace$
DefVar $InstallDir$
DefVar $ExitCode$
DefVar $LicenseRequired$
DefVar $LicenseKey$
DefVar $LicensePool$
Set $LogDir$ = "%SystemDrive%\tmp"
; ----------------------------------------------------------------
; - Please edit the following values -
; ----------------------------------------------------------------
;$ProductId$ should be the name of the product in opsi
; therefore please: only lower letters, no umlauts,
; no white space use '-' as a seperator
Set $ProductId$ = "spark"
Set $MinimumSpace$ = "30 MB"
; the path were we find the product after the installation
Set $InstallDir$ = "%ProgramFiles32Dir%\spark"
Set $LicenseRequired$ = "false"
Set $LicensePool$ = "p_" + $ProductId$
; ----------------------------------------------------------------
if not(HasMinimumSpace ("%SystemDrive%", $MinimumSpace$))
LogError "Plus assez d'espace sur %SystemDrive%, " + $MinimumSpace$ + " sur le disque %SystemDrive% sont requis pour installer " + $ProductId$
isFatalError "Plus d'espace disque"
; Stop process and set installation status to failed
else
comment "Show product picture"
ShowBitmap "%ScriptPath%\" + $ProductId$ + ".png" $ProductId$
if FileExists("%ScriptPath%\delsub32.ins")
comment "Start uninstall sub section"
Sub "%ScriptPath%\delsub32.ins"
endif
Message "Installation en cours : " + $ProductId$
if $LicenseRequired$ = "true"
comment "Licence requise, reserve license and get license key"
Sub_get_licensekey
endif
comment "Start setup program"
ChangeDirectory "%SCRIPTPATH%"
Winbatch_install
Sub_check_exitcode
comment "Execute the program"
DOSInAnIcon_1 winst /32Bit
comment "Copy files"
Files_install /32Bit
comment "Patch Registry"
Registry_install /32Bit
comment "Create shortcuts"
LinkFolder_install
endif
[Winbatch_install]
; Choose one of the following examples as basis for your installation
; You can use $LicenseKey$ var to pass a license key to the installer
;
; === Nullsoft Scriptable Install System ================================================================
; "%ScriptPath%\spark_2_8_3.exe" /S
;
; === MSI package =======================================================================================
; You may use the parameter PIDKEY=$Licensekey$
msiexec /i "%ScriptPath%\Spark.msi"/qn /norestart
;
; === InstallShield + MSI=====================================================================================
; Attention: The path to the log file should not contain any whitespaces
; "%ScriptPath%\setup.exe" /s /v" /l* $LogDir$\$ProductId$.install_log.txt /qb! ALLUSERS=1 REBOOT=ReallySuppress"
; "%ScriptPath%\setup.exe" /s /v" /qb! ALLUSERS=2 REBOOT=ReallySuppress"
;
; === InstallShield =====================================================================================
; Create setup.iss answer file by running: setup.exe /r /f1"c:\setup.iss"
; You may use an answer file by the parameter /f1"c:\setup.iss"
; "%ScriptPath%\setup.exe" /s /sms /f2"$LogDir$\$ProductId$.install_log.txt"
;
; === Inno Setup ========================================================================================
; http://unattended.sourceforge.net/InnoS ... Codes.html
; You may create setup answer file by: setup.exe /SAVEINF="filename"
; You may use an answer file by the parameter /LOADINF="filename"
; "%ScriptPath%\setup.exe" /sp- /silent /norestart /nocancel /SUPPRESSMSGBOXES
[DOSInAnIcon_1]
; Commandes batch de Windows (sans affichage de l'invite de commandes)
@echo off
cd "%AppDataDir%"
mkdir Spark
; start Spark.exe
; ping 127.0.0.1 -n 5
; taskkill /f /im spark.exe
[Files_install]
; Example of recursively copying some files into the installation directory:
copy -s "%ScriptPath%\spark.properties" "%CurrentAppDataDir%\Spark\"
[Registry_install]
; Example of setting some values of an registry key:
;
openkey [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Search\UsnNotifier\Windows\Catalogs\SystemIndex]
set "{1337E3EF-24E8-11E7-B165-806E6F6E6963}" = REG_DWORD:11169827240
; set "name2" = REG_DWORD:0001
; set "name3" = REG_BINARY:00 af 99 cd
[LinkFolder_install]
; Example of deleting a folder from AllUsers startmenu:
;
; set_basefolder common_programs
; delete_subfolder $ProductId$
;
; Example of creating an shortcut to the installed exe in AllUsers startmenu:
;
; set_basefolder common_programs
; set_subfolder $ProductId$
;
; set_link
; name: $ProductId$
; target: <path to the program>
; parameters:
; working_dir: $InstallDir$
; icon_file:
; icon_index:
; end_link
;
; Example of creating an shortcut to the installed exe on AllUsers desktop:
;
; set_basefolder common_desktopdirectory
; set_subfolder ""
;
; set_link
; name: $ProductId$
; target: <path to the program>
; parameters: <some_param>
; working_dir: $InstallDir$
; icon_file: <path to icon file>
; icon_index: 2
; end_link
[Sub_get_licensekey]
if opsiLicenseManagementEnabled
comment "License management is enabled and will be used"
comment "Trying to get a license key"
Set $LicenseKey$ = demandLicenseKey ($LicensePool$)
; If there is an assignment of exactly one licensepool to the product the following call is possible:
; Set $LicenseKey$ = demandLicenseKey ("", $ProductId$)
;
; If there is an assignment of a license pool to a windows software id, it is possible to use:
; DefVar $WindowsSoftwareId$
; $WindowsSoftwareId$ = "..."
; Set $LicenseKey$ = demandLicenseKey ("", "", $WindowsSoftwareId$)
DefVar $ServiceErrorClass$
set $ServiceErrorClass$ = getLastServiceErrorClass
comment "Error class: " + $ServiceErrorClass$
if $ServiceErrorClass$ = "None"
comment "Everything fine, we got the license key '" + $LicenseKey$ + "'"
else
if $ServiceErrorClass$ = "LicenseConfigurationError"
LogError "Fatal: license configuration must be corrected"
LogError getLastServiceErrorMessage
isFatalError
else
if $ServiceErrorClass$ = "LicenseMissingError"
LogError "Fatal: required license is not supplied"
isFatalError
endif
endif
endif
else
LogError "Fatal: license required, but license management not enabled"
isFatalError
endif
[Sub_check_exitcode]
comment "Test for installation success via exit code"
set $ExitCode$ = getLastExitCode
; informations to exit codes see
if ($ExitCode$ = "0")
comment "Looks good: setup program gives exitcode zero"
else
comment "Setup program gives a exitcode unequal zero: " + $ExitCode$
if ($ExitCode$ = "1605")
comment "ERROR_UNKNOWN_PRODUCT 1605 This action is only valid for products that are currently installed."
comment "Uninstall of a not installed product failed - no problem"
else
if ($ExitCode$ = "1641")
comment "looks good: setup program gives exitcode 1641"
comment "ERROR_SUCCESS_REBOOT_INITIATED 1641 The installer has initiated a restart. This message is indicative of a success."
else
if ($ExitCode$ = "3010")
comment "looks good: setup program gives exitcode 3010"
comment "ERROR_SUCCESS_REBOOT_REQUIRED 3010 A restart is required to complete the install. This message is indicative of a success."
else
logError "Fatal: Setup program gives an unknown exitcode unequal zero: " + $ExitCode$
isFatalError
endif
endif
endif
endif
Do you have an idea? Do I have to declare new variables at the beginning of my script? I mean these variables: %AppdataDir% or %CurrentAppdataDir%. I thought they were already known by OPSI. Besides I don't understand as I am using Dos commands so I should use Dos variables recognized by Windows like %AppData% but not %AppDataDir% as I am in my [DOSInAnIcon_1] section writing these commands.
Sorry if I am not very clear, I am a beginner in OPSI and also in scripting: headache
![Smile :)](./images/smilies/icon_e_smile.gif)
Thanks in advance for your help. Have a nice evening or a nice day or weekend (soon).
Siming