Syntax Fehler-Script-Neuling

seemax1991
Beiträge: 38
Registriert: 14 Jan 2013, 14:51

Syntax Fehler-Script-Neuling

Beitrag von seemax1991 »

Moin Moin,

ich bin leider noch nicht so ganz mit der Syntax vertraut.
Kann mir einer sagen wo ich hier einen Fehler gemacht habe?

Code: Alles auswählen

if FileExists("("+$InstallDir$+"\"+$ProductName$+"\"+$UninstallPath$")")
    set $UninstallProgram$ = "("+$InstallDir$+"\"+$ProductName$+"\"+$UninstallPath$")"
    set $UninstallCommand$ = '"'+$UninstallProgram$+'" $UninstallSilentSwitch$'
    WinBatch_uninstall /WaitSeconds 10
    sub_check_exitcode
endif
Ich vermute mal ich habe das mit den () und "" noch nicht so ganz verstanden.
Die Variablen sind soweit korrekt wie ich meine, aber der Zusammenbau mehrere Variablen zu einer...
das will noch nicht.
Auszubildender Fachinformatiker
dkoch
Beiträge: 309
Registriert: 25 Nov 2011, 14:03

Re: Syntax Fehler-Script-Neuling

Beitrag von dkoch »

Code: Alles auswählen

if FileExists ("$InstallDir$ + "\" + $ProductName$ + "\" + $UninstallPath$")
    set $UninstallProgram$ = $InstallDir$+"\"+$ProductName$+"\"+$UninstallPath$"
   set $UninstallCommand$ = $UninstallProgram$ + " " +$UninstallSilentSwitch$
    WinBatch_uninstall /WaitSeconds 10
    sub_check_exitcode
endif
Könnte passen. Wenn deine Variablen so gefüllt sind wie ich mir das denke
seemax1991
Beiträge: 38
Registriert: 14 Jan 2013, 14:51

Re: Syntax Fehler-Script-Neuling

Beitrag von seemax1991 »

dkoch hat geschrieben:

Code: Alles auswählen

if FileExists ("$InstallDir$ + "\" + $ProductName$ + "\" + $UninstallPath$")
    set $UninstallProgram$ = $InstallDir$+"\"+$ProductName$+"\"+$UninstallPath$"
   set $UninstallCommand$ = $UninstallProgram$ + " " +$UninstallSilentSwitch$
    WinBatch_uninstall /WaitSeconds 10
    sub_check_exitcode
endif
Könnte passen. Wenn deine Variablen so gefüllt sind wie ich mir das denke
Ouu, guter Mann!
ich nseh schon was ich da vergurkt hab xD
Danke dir.
Ja hätte besser mal SET's mit hinschreiben sollen, sorry.
Vielen Dank für die Hilfe :D
Auszubildender Fachinformatiker
seemax1991
Beiträge: 38
Registriert: 14 Jan 2013, 14:51

Re: Syntax Fehler-Script-Neuling

Beitrag von seemax1991 »

Code: Alles auswählen

;-------------Diese Werte abaendern---------------------
Set $LogDir$			= "%SystemDrive%\tmp"
Set $ProductId$			= "firefox24.5esr"
Set $ProductName$		= "Mozilla Firefox"
Set $ProcessName$		= "firefox.exe"
Set $MinimumSpace$		= "500 MB"
Set $InstallDir$		= "%ProgramFiles32Dir%"
Set $InstallSilentSwitch$	= "[/INI=mfconf.ini]"
Set $UninstallSilentSwitch$	= "/S"
Set $UninstallPath$		= "uninstall\helper.exe"
;-------------------------------------------------------
Das waren die Set's ;)
Auszubildender Fachinformatiker
Benutzeravatar
SisterOfMercy
Beiträge: 1524
Registriert: 22 Jun 2012, 19:18

Re: Syntax Fehler-Script-Neuling

Beitrag von SisterOfMercy »

I think it would be better to not include the version number in the product-id. When 24.6.0 is released you would have an outdated product-id or would have to make a new product.

Based on the advice given to me in the forum one could choose for these product-ids:
mozilla-firefox
mozilla-firefox-esr (when running the non-esr version as well)
or simpler:
firefox
firefox-esr

Code: Alles auswählen

Set $InstallSilentSwitch$   = "[/INI=mfconf.ini]"
Why the []-brackets?
Bitte schreiben Sie Deutsch, when I'm responding in the German-speaking part of the forum!
seemax1991
Beiträge: 38
Registriert: 14 Jan 2013, 14:51

Re: Syntax Fehler-Script-Neuling

Beitrag von seemax1991 »

Hi m8 and thanks for replying,
I think it would be better to not include the version number in the product-id
I thought so too. But lately we got the circumstances changing: Sometimes we have to install different versions of different products on some of our companys departments. So I would be in need to produce a new product with version identifier anyways. So I thought: Do it easy and just put it into the name of the product so I'm able to idetify the package immediatly.
mozilla-firefox
mozilla-firefox-esr (when running the non-esr version as well)
or simpler:
firefox
firefox-esr
These are quite some good names. I might will change mine to: mozilla-firefox-esr-24.5
Why the []-brackets?
Says so in the mozilla wiki click me
Silent install (always installs into the default location. Use the "Configuration ini file" option below to set the install location and other install options):
<path to setup executable> -ms

Silent uninstall:
<path to setup executable> /S

Configuration ini file:
<path to setup executable> [/INI=<full path to configuration ini file>]
Auszubildender Fachinformatiker
Benutzeravatar
SisterOfMercy
Beiträge: 1524
Registriert: 22 Jun 2012, 19:18

Re: Syntax Fehler-Script-Neuling

Beitrag von SisterOfMercy »

seemax1991 hat geschrieben:
Why the []-brackets?
Says so in the mozilla wiki click me
Oh, I read that as optional. :D
My version does not include brackets, and does not install the maintenance service, so I think it works either way. Which is good, I would _not_ have found out this myself if it didn't work without brackets!
Bitte schreiben Sie Deutsch, when I'm responding in the German-speaking part of the forum!
seemax1991
Beiträge: 38
Registriert: 14 Jan 2013, 14:51

Re: Syntax Fehler-Script-Neuling

Beitrag von seemax1991 »

Okay... jetzt bin ichlangsam echt etwas Ratlos. Excpeted >")< interessanter weise der gleiche Fehler wie vorher. Trotz anderem Code.

Setup.ins

Code: Alles auswählen

[Initial]
 
Message = Bitte warten, das Produkt wird installiert...
setLogLevel = 9
ExitOnError = false
ScriptErrorMessages = on
TraceMode = off
StayOnTop = false

[Actions]

DefVar $LogDir$
DefVar $ProductId$  
DefVar $ProductName$
DefVar $ProcessName$
DefVar $MinimumSpace$
DefVar $InstallDir$
DefVar $InstallSilentSwitch$
DefVar $UninstallSilentSwitch$
DefVar $ExitCode$
DefVar $UninstallProgram$
DefVar $UninstallCommand$
DefVar $UninstallPath$

;-------------Diese Werte abaendern---------------------
Set $LogDir$			= "%SystemDrive%\tmp"
Set $ProductId$			= "firefox24.5esr"
Set $ProductName$		= "Mozilla Firefox"
Set $ProcessName$		= "firefox.exe"
Set $MinimumSpace$		= "500 MB"
Set $InstallDir$		= "%ProgramFiles32Dir%"
Set $InstallSilentSwitch$	= "[/INI=mfconf.ini]"
Set $UninstallSilentSwitch$	= "/S"
Set $UninstallPath$		= "uninstall\helper.exe"
;NACH diesem Bereich, duerfen keine programmspezifischen Angaben
;mehr existieren - es darf nur noch mit Variablen gearbeitet werden!
;-------------------------------------------------------

if not(HasMinimumSpace ("%SystemDrive%", $MinimumSpace$))
	LogError "Nicht ausreichend Speicherplatz auf %SystemDrive%, " + $MinimumSpace$ + " auf Festplatte %SystemDrive% benoetigt zur Installation von " + $ProductId$
	isFatalError "Unzureichender Festplattenspeicher"
	; Stopt den Prozess und setzt die Installation des Paketes auf den Status failed
else
	comment "Zeige Produktbild"
	ShowBitmap "%ScriptPath%\" + $ProductId$ + ".png"
		
		if FileExists("%ScriptPath%\delsub.ins")
			comment "starte del-subroutine"
			sub "%ScriptPath%\delsub.ins"
		endif

	Message "Installiere " + $ProductName$ + " ..."
	comment "Starte Setup"
	comment "beende(hart) laufenden Programmprozess, sofern vorhanden..."
	killtask $ProcessName$
	ChangeDirectory "%SCRIPTPATH%"
	Winbatch_install
	Sub_check_exitcode
endif

[Winbatch_install]
; === Nullsoft Scriptable Install System ================================================================
"%ScriptPath%\" + $ProductId$ + ".exe" + " " + $InstallSilentSwitch$
;
; === MSI package =======================================================================================
; msiexec /i "%ScriptPath%\some.msi" /l* "$LogDir$\$ProductId$.install_log.txt" /qb! ALLUSERS=1 REBOOT=ReallySuppress
;
; === InstallShield + MSI=====================================================================================
; "%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"
;

[Sub_check_exitcode]
comment "Installationstest via Exitcode-Ueberpruefung"
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
;Author Jan-Philipp Juergens
if ($ExitCode$ = "0")
	comment "Sieht gut aus: Setup gibt einen Exitcode gleich null aus"
else
	comment "Installationsprogramm - unbekannter Exitcode ungleich null: " + $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 "Sieht gut aus: Setup gibt folgenden Exitcode aus: 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 "Sieht gut aus: Setup gibt folgenden Exitcode aus: 3010"
				comment "ERROR_SUCCESS_REBOOT_REQUIRED	3010	A restart is required to complete the install. This message is indicative of a success."
			else
				logError "Kritisch: Installationsprogramm gibt einen unbekannten Exitcode ungleich null an: " + $ExitCode$
				isFatalError
			endif
		endif
	endif
endif
Delsub.ins

Code: Alles auswählen

;************************************************************
;
;delsub.ins
;
;************************************************************
 

Message "Deinstalliere " + $ProductId$ + " ..."
comment "beende(hart) laufenden Programmprozess, sofern vorhanden..."
killtask $ProcessName$

if FileExists ("$InstallDir$ + "\" + $ProductName$ + "\" + $UninstallPath$")
    set $UninstallProgram$ = $InstallDir$+"\"+$ProductName$+"\"+$UninstallPath$"
    set $UninstallCommand$ = $UninstallProgram$ + " " +$UninstallSilentSwitch$'
    WinBatch_uninstall /WaitSeconds 10
    sub_check_exitcode
endif

[WinBatch_uninstall]
$UninstallCommand$
;%SCRIPTPATH%\sleep 5

[sub_check_exitcode]
comment "Installationstest via Exitcode-Ueberpruefung"
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
;Author Jan-Philipp Juergens
if ($ExitCode$ = "0")
	comment "Sieht gut aus: Setup gibt einen Exitcode gleich null aus"
else
	comment "Installationsprogramm - unbekannter Exitcode ungleich null: " + $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 "Sieht gut aus: Setup gibt folgenden Exitcode aus: 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 "Sieht gut aus: Setup gibt folgenden Exitcode aus: 3010"
				comment "ERROR_SUCCESS_REBOOT_REQUIRED	3010	A restart is required to complete the install. This message is indicative of a success."
			else
				logError "Kritisch: Installationsprogramm gibt einen unbekannten Exitcode ungleich null an: " + $ExitCode$
				isFatalError
			endif
		endif
	endif
endif
Uninstall.ins

Code: Alles auswählen

[Initial]
 
Message = Bitte warten, das Produkt wird deinstalliert...
setLogLevel = 9
ExitOnError = false
ScriptErrorMessages = on
TraceMode = off
StayOnTop = false

[Actions]

DefVar $LogDir$
DefVar $ProductId$  
DefVar $ProductName$
DefVar $ProcessName$
DefVar $MinimumSpace$
DefVar $InstallDir$
DefVar $InstallSilentSwitch$
DefVar $UninstallSilentSwitch$
DefVar $ExitCode$
DefVar $UninstallProgram$
DefVar $UninstallCommand$
DefVar $UninstallPath$

;-------------Diese Werte abaendern---------------------
Set $LogDir$			= "%SystemDrive%\tmp"
Set $ProductId$			= "firefox24.5esr"
Set $ProductName$		= "Mozilla Firefox"
Set $ProcessName$		= "firefox.exe"
Set $MinimumSpace$		= "500 MB"
Set $InstallDir$		= "%ProgramFiles32Dir%"
Set $InstallSilentSwitch$	= "[/INI=mfconf.ini]"
Set $UninstallSilentSwitch$	= "/S"
Set $UninstallPath$		= "uninstall\helper.exe"
;NACH diesem Bereich, duerfen keine programmspezifischen Angaben
;mehr existieren - es darf nur noch mit Variablen gearbeitet werden!
;-------------------------------------------------------

comment "Zeige Produktbild"
ShowBitmap "%ScriptPath%\" + $ProductId$ + ".png"
Message "Deinstalliere " + $ProductName$ + " ..."
comment "Starte Setup"
comment "beende(hart) laufenden Programmprozess, sofern vorhanden..."
killtask $ProcessName$
ChangeDirectory "%SCRIPTPATH%"

if FileExists("%ScriptPath%\delsub.ins")
	comment "starte del-subroutine"
	sub "%ScriptPath%\delsub.ins"
endif

EDIT:
habe ich hier einen erkennbaren Fehler gemacht o.O?

Code: Alles auswählen

set $UninstallProgram$ = $InstallDir$+"\"+$ProductName$+"\"+$UninstallPath$"
Auszubildender Fachinformatiker
Benutzeravatar
koepkek
uib-Team
Beiträge: 255
Registriert: 11 Jan 2012, 11:27

Re: Syntax Fehler-Script-Neuling

Beitrag von koepkek »

Hallo

bitte mal im GettingStarted-Handbuch lesen zum Thema
5.1.8 Elementare Befehle für primäre Sektionen
5.1.8.1 String-Variable

Die +-Zeichen zum Verketten von Variablen sind nur in den primären Sektionen notwendig.

Im Instlog.txt sollte doch eigentlich ersichtlich sein, wo dein Problem ist.

Freundliche Grüße
Karsten Köpke
opsi support - uib gmbh
For productive opsi installations we recommend support contracts.
http://uib.de
http://opsi.org
seemax1991
Beiträge: 38
Registriert: 14 Jan 2013, 14:51

Re: Syntax Fehler-Script-Neuling

Beitrag von seemax1991 »

koepkek hat geschrieben:Hallo

bitte mal im GettingStarted-Handbuch lesen zum Thema
5.1.8 Elementare Befehle für primäre Sektionen
5.1.8.1 String-Variable

Die +-Zeichen zum Verketten von Variablen sind nur in den primären Sektionen notwendig.

Im Instlog.txt sollte doch eigentlich ersichtlich sein, wo dein Problem ist.

Freundliche Grüße
Karsten Köpke
Werde mir das jetzt bei Zeiten mal komplett durchlesen,
leider wird einem für solche Dinge meist kaum Arbeitszeit zugestanden, echt schade :(
Kann man eigentlich fertige OPSI Pakete irgendwo mit anderen teilen?
(natürlich nur welche die auch wirklich funktionieren)
Würde meine da gerne irgendwann anbieten. Auch wenn diese dann vermutlich nur sehr sehr simpel sein werden.
(Für andere Anfänger vielleicht nicht verkehrt)

-Seemax
Auszubildender Fachinformatiker
Antworten