[Gelöst] Import eines Reg-Files bringt Fehler: EdnIf -> expected

Antworten
MyKey0815
Beiträge: 65
Registriert: 01 Jul 2008, 17:15

[Gelöst] Import eines Reg-Files bringt Fehler: EdnIf -> expected

Beitrag von MyKey0815 »

Ich habe einen Setup-Script genommen, der mir TeamViewer installieren soll. Damit ein paar Einstellungen gemacht werden können, habe ich diese von einem Windows10 Rechner exportiert und will dieses Reg-File nun vor der eigentlichen Installation wieder einspielen

Code: Alles auswählen

registry loadunicodetextfile("%SCRIPTPATH%\X86\TeamViewer12.reg") /32bit /regedit
Leider kommt aber der Fehler:

"Syntax Error in Section: Actions ....: EndIf -> expected"

Das die Ursache der Reg-Import ist, kann ich damit nachstellen, wenn ich die Zeile deaktiviere, dass dann TeamViewer installiert wird - zwar ohne die Einstellungen, aber es läuft durch.

Was könnte die Ursache sein oder was fehlt noch
Zuletzt geändert von MyKey0815 am 16 Feb 2018, 11:23, insgesamt 1-mal geändert.
uncle_scrooge
Beiträge: 650
Registriert: 21 Feb 2012, 12:03
Wohnort: Mainz

Re: Import eines Reg-Files bringt Fehler: EdnIf -> expected

Beitrag von uncle_scrooge »

Bitte das ganze Skript einstellen.

Wenn WINST ein 'ENDIF expected' wirft, dürfte es wohl irgendwo ein verwaistes 'IF' geben.
MyKey0815
Beiträge: 65
Registriert: 01 Jul 2008, 17:15

Re: Import eines Reg-Files bringt Fehler: EdnIf -> expected

Beitrag von MyKey0815 »

Hier der gesamte Script

Wenn ich die Zeile mit dem Regimport mit einem ";" markiere, dann läuft es aber durch

Code: Alles auswählen

; Copyright (c) uib gmbh (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 $UninstallProgram$
DefVar $UninstallProgramOld$
DefVar $IniFile$
DefVar $IniCfgFile$
DefVar $LogDir$
DefVar $ProductId$  
DefVar $MinimumSpace$
DefVar $InstallDir$
DefVar $ExitCode$
DefVar $OLD_VERSION$
DefVar $OLD_CREATOR_TAG$
DefVar $OLD_RELEASE$

Set $LogDir$ = "%SystemDrive%\tmp"

; The token BUILDER_VARIABLES will be replaced by opsi-builder.sh
; and adds the following variables:
;   from builder-product.cfg :  all variables definded by attribute WINST[index]
;   from builder-product.cfg :  VENDOR PN VERSION RELEASE PRIORITY ADVICE TYPE   
;   from opsi-builder.cfg    :  CREATOR_TAG CREATOR_NAME CREATOR_EMAIL           
;   auto generated winst-variables
;         $IconFile$: path to product picture
;
; Opsi Builder Variables
DefVar $PackagePath$
Set    $PackagePath$ = "%ScriptPath%"

DefVar $InstallExe$
Set    $InstallExe$ = $PackagePath$ + "\X86\TeamViewer_Setup_de-12.0.83369.exe"
DefVar $VENDOR$
Set    $VENDOR$ = "teamviewer.com"
DefVar $PN$
Set    $PN$ = "teamviewer.teamviewer12"
DefVar $VERSION$
Set    $VERSION$ = "12.0.83369"
DefVar $RELEASE$
Set    $RELEASE$ = "1"
DefVar $PRIORITY$
Set    $PRIORITY$ = "0"
DefVar $NAME$
Set    $NAME$ = "TeamViewer 12"
DefVar $ADVICE$
Set    $ADVICE$ = ""
DefVar $TYPE$
Set    $TYPE$ = "public"
DefVar $CREATOR_TAG$
Set    $CREATOR_TAG$ = "go"
DefVar $CREATOR_NAME$
Set    $CREATOR_NAME$ = "Mario Fetka"
DefVar $CREATOR_EMAIL$
Set    $CREATOR_EMAIL$ = "mario.fetka@gmail.com"
DefVar $IconFile$
Set    $IconFile$ = "%ScriptPath%\teamviewer.teamviewer12.png"

; Opsi INI File Variables

DefVar $UninstallProg$
Set    $UninstallProg$ = "uninstall.exe"

;Hardcoded opsi vars
Set    $ProductId$ = "teamviewer.teamviewer12"

; ----------------------------------------------------------------
; - 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 $MinimumSpace$    = "20 MB"
; the path were we find the product after the installation
Set $InstallDir$      = "%ProgramFiles32Dir%\TeamViewer\Version12"
; ----------------------------------------------------------------

Set $IniCfgFile$ = "%ScriptPath%\opsi-" + $ProductId$ + ".ini"

if not(HasMinimumSpace ("%SystemDrive%", $MinimumSpace$))
	LogError "Not enough space on %SystemDrive%, " + $MinimumSpace$ + " on drive %SystemDrive% needed for " + $ProductId$
	isFatalError "No Space"
	; Stop process and set installation status to failed
else
	comment "Show product picture"
	ShowBitmap "%ScriptPath%\" + $ProductId$ + ".png" $NAME$
	
	if FileExists("%ScriptPath%\delsub32.ins")
		comment "Start uninstall sub section"
		Sub "%ScriptPath%\delsub32.ins"
	endif
	
	Message "Installing " + $ProductId$ + " "+ $VERSION$ + "-" + $CREATOR_TAG$ + $RELEASE$ + " ..."
	
	comment "Start setup program"
	ChangeDirectory "%SCRIPTPATH%"
	
	registry loadunicodetextfile("%SCRIPTPATH%\X86\TeamViewer12.reg") /32bit /regedit
	Winbatch_install
	Sub_check_exitcode
	
	sleepSeconds 3
	comment "Close the Teamviewer Windows"
	killtask "TeamViewer.exe"

	comment "Copy files"
	Files_install /32Bit
	
	comment "Patch Registry"
	Registry_install /32Bit
	
	comment "Create shortcuts"
	LinkFolder_install
	
endif

[Winbatch_install]
"$InstallExe$" /S

[Files_install]
; copy the ini file to the InstallDir
copy "$IniCfgFile$" "$InstallDir$"

; Example of recursively copying some files into the installation directory:
;
; copy -s "%ScriptPath%\files\*.*" "$InstallDir$"

[Registry_install]
; Example of setting some values of an registry key:
;
; openkey [HKEY_LOCAL_MACHINE\Software\$ProductId$]
; set "name1" = "some string value"
; set "name2" = REG_DWORD:0001
; set "name3" = REG_BINARY:00 af 99 cd

[LinkFolder_install]
set_basefolder common_desktopdirectory
set_subfolder ""
delete_element "TeamViewer 12"

; 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_check_exitcode]
comment "Test for installation success via exit code"
set $ExitCode$ = getLastExitCode
; informations to exit codes see
; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
; http://msdn.microsoft.com/en-us/library/aa368542.aspx
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
uncle_scrooge
Beiträge: 650
Registriert: 21 Feb 2012, 12:03
Wohnort: Mainz

Re: Import eines Reg-Files bringt Fehler: EdnIf -> expected

Beitrag von uncle_scrooge »

Mach aus dem 'else' ein 'endif', und nimm vor [Winbatch_install] das endif raus.
Damit funktioniert bei mir der Registry-Call.
MyKey0815
Beiträge: 65
Registriert: 01 Jul 2008, 17:15

Re: Import eines Reg-Files bringt Fehler: EdnIf -> expected

Beitrag von MyKey0815 »

Vielen Dank für die Antwort - nun scheint das "EndIf" tatsächlich weg zu sein.

Ursache ist aber das Reg-File. Dort sind Einträge drin wie:

Code: Alles auswählen

"Proxy_IP"=hex(1):00,00
"ProxyUsername"=hex(1):00,00
"ProxyPasswordAES"=hex(3):88,44,d7,63,16,3c,ff,e4,15,04,fb
Bei der Ausführung führt das zu Fehlern wie:
"hex(1) is a not supported type of a registry entry"
uncle_scrooge
Beiträge: 650
Registriert: 21 Feb 2012, 12:03
Wohnort: Mainz

Re: Import eines Reg-Files bringt Fehler: EdnIf -> expected

Beitrag von uncle_scrooge »

Dann bau Dir entweder das

[Winbatch_regedit_s_64]
"%systemroot%\regedit.exe" /s "%scriptpath%\test-files\64bit.reg"

oder das

[Winbatch_regedit_s_32]
"%system%\regedit.exe" /s "%scriptpath%\test-files\64bit.reg"

(Geklaut aus Paket OPSI-WINST-TEST)

Zumindest Win7/Win10 exportieren REG_EXPAND_SZ als hex. Und das mag der Registry-Call augenscheinlich überhaupt nicht.
Antworten