exit codes

Antworten
Benutzeravatar
SisterOfMercy
Beiträge: 1556
Registriert: 22 Jun 2012, 19:18

exit codes

Beitrag von SisterOfMercy »

Code: Alles auswählen

set $ExitCode$ = getLastExitCode
This gives us an exitcode, but is it also possible to get the extra codes? An example to make this more clear:

Code: Alles auswählen

MSI (s) (F4:18) [15:31:14:605]: Note: 1: 1707 
MSI (s) (F4:18) [15:31:14:605]: Product: LibreOffice 5.0.3.2 -- Installation operation completed successfully.

MSI (s) (F4:18) [15:31:14:605]: Windows Installer installed the product. Product Name: LibreOffice 5.0.3.2. Product Version: 5.0.3.2. Product Language: 1033. Installation success or error status: 0.
The exitcode in this case would be 0. However, code 1707 is also an exitcode, from here: https://msdn.microsoft.com/en-us/librar ... 85%29.aspx

Sometimes it can be very handy to get all these codes. For instance, exitcode 1603, 'A fatal error occurred during installation.' can have a lot of reasons, and it would be nice to not have to read the verbose MSI log file by default.
Bitte schreiben Sie Deutsch, when I'm responding in the German-speaking part of the forum!
Benutzeravatar
ueluekmen
uib-Team
Beiträge: 1940
Registriert: 28 Mai 2008, 10:53

Re: exit codes

Beitrag von ueluekmen »

Hi,

the exitcodes is everytime the last one. In this case its the installer for msi files. If you want to check all the internal exitcodes you have to analyse the logfile, how you want to react with this informations? For example you install 7zip and you get

1603
3030
1987
-210384646739
0

which one will say that the installation is failed or succesfull? That you become different exitcodes during the installation is normal because the msi installer checks much stuff, that is not used in every msi-File. So you get an errorcode in this place. But it says nothing about the installationstate.


Vielen Dank für die Nutzung von opsi. Im Forum ist unser Support begrenzt.

Für den professionellen Einsatz und individuelle Beratung empfehlen wir einen Support-Vertrag und eine Schulung.
Gerne informieren wir Sie zu unserem Angebot.

uib GmbH
Telefon: +49 6131 27561 0
E-Mail: sales@uib.de


Benutzeravatar
SisterOfMercy
Beiträge: 1556
Registriert: 22 Jun 2012, 19:18

Re: exit codes

Beitrag von SisterOfMercy »

ueluekmen hat geschrieben:the exitcodes is everytime the last one. In this case its the installer for msi files. If you want to check all the internal exitcodes you have to analyse the logfile, how you want to react with this informations?
Hmmm, yes I thought it would be somewhat impossible like this.

Anyway, so how about this include file:

Code: Alles auswählen

;opsi include file

DefVar $ExitCode$
DefVar $RebootStatus$

[Sub_check_msi_exitcode]
set $ExitCode$ = getLastExitCode
; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
; http://msdn.microsoft.com/en-us/library/aa368542.aspx
Switch $ExitCode$
	Case "0"
		comment "ERROR_SUCCESS	0	The action completed successfully."
	EndCase
	Case "13"
		isFatalError "ERROR_INVALID_DATA	13	The data is invalid."
	EndCase
	Case "87"
		isFatalError "ERROR_INVALID_PARAMETER	87	One of the parameters was invalid."
	EndCase
	Case "120"
		isFatalError "ERROR_CALL_NOT_IMPLEMENTED	120	This value is returned when a custom action attempts to call a function that cannot be called from custom actions."
	EndCase
	Case "1259"
		isFatalError "ERROR_APPHELP_BLOCK	1259	If Windows Installer determines a product may be incompatible with the current operating system, it displays a dialog box informing the user and asking whether to try to install anyway. This error code is returned if the user chooses not to try the installation."
	EndCase
	Case "1601"
		isFatalError "ERROR_INSTALL_SERVICE_FAILURE	1601	The Windows Installer service could not be accessed. Contact your support personnel to verify that the Windows Installer service is properly registered."
	EndCase
	Case "1602"
		isFatalError "ERROR_INSTALL_USEREXIT	1602	The user cancels installation."
	EndCase
	Case "1603"
		isFatalError "ERROR_INSTALL_FAILURE	1603	A fatal error occurred during installation."
	EndCase
	Case "1604"
		isFatalError "ERROR_INSTALL_SUSPEND	1604	Installation suspended, incomplete."
	EndCase
	Case "1605"
		comment "ERROR_UNKNOWN_PRODUCT	1605	This action is only valid for products that are currently installed."
	EndCase
	Case "1606"
		isFatalError "ERROR_UNKNOWN_FEATURE	1606	The feature identifier is not registered."
	EndCase
	Case "1607"
		isFatalError "ERROR_UNKNOWN_COMPONENT	1607	The component identifier is not registered."
	EndCase
	Case "1608"
		isFatalError "ERROR_UNKNOWN_PROPERTY	1608	This is an unknown property."
	EndCase
	Case "1609"
		isFatalError "ERROR_INVALID_HANDLE_STATE	1609	The handle is in an invalid state."
	EndCase
	Case "1610"
		isFatalError "ERROR_BAD_CONFIGURATION	1610	The configuration data for this product is corrupt. Contact your support personnel."
	EndCase
	Case "1611"
		isFatalError "ERROR_INDEX_ABSENT	1611	The component qualifier not present."
	EndCase
	Case "1612"
		isFatalError "ERROR_INSTALL_SOURCE_ABSENT	1612	The installation source for this product is not available. Verify that the source exists and that you can access it."
	EndCase
	Case "1613"
		isFatalError "ERROR_INSTALL_PACKAGE_VERSION	1613	This installation package cannot be installed by the Windows Installer service. You must install a Windows service pack that contains a newer version of the Windows Installer service."
	EndCase
	Case "1614"
		isFatalError "ERROR_PRODUCT_UNINSTALLED	1614	The product is uninstalled."
	EndCase
	Case "1615"
		isFatalError "ERROR_BAD_QUERY_SYNTAX	1615	The SQL query syntax is invalid or unsupported."
	EndCase
	Case "1616"
		isFatalError "ERROR_INVALID_FIELD	1616	The record field does not exist."
	EndCase
	Case "1618"
		isFatalError "ERROR_INSTALL_ALREADY_RUNNING	1618	Another installation is already in progress. Complete that installation before proceeding with this install."
	EndCase
	Case "1619"
		isFatalError "ERROR_INSTALL_PACKAGE_OPEN_FAILED	1619	This installation package could not be opened. Verify that the package exists and is accessible, or contact the application vendor to verify that this is a valid Windows Installer package."
	EndCase
	Case "1620"
		isFatalError "ERROR_INSTALL_PACKAGE_INVALID	1620	This installation package could not be opened. Contact the application vendor to verify that this is a valid Windows Installer package."
	EndCase
	Case "1621"
		isFatalError "ERROR_INSTALL_UI_FAILURE	1621	There was an error starting the Windows Installer service user interface. Contact your support personnel."
	EndCase
	Case "1622"
		isFatalError "ERROR_INSTALL_LOG_FAILURE	1622	There was an error opening installation log file. Verify that the specified log file location exists and is writable."
	EndCase
	Case "1623"
		isFatalError "ERROR_INSTALL_LANGUAGE_UNSUPPORTED	1623	This language of this installation package is not supported by your system."
	EndCase
	Case "1624"
		isFatalError "ERROR_INSTALL_TRANSFORM_FAILURE	1624	There was an error applying transforms. Verify that the specified transform paths are valid."
	EndCase
	Case "1625"
		isFatalError "ERROR_INSTALL_PACKAGE_REJECTED	1625	This installation is forbidden by system policy. Contact your system administrator."
	EndCase
	Case "1626"
		isFatalError "ERROR_FUNCTION_NOT_CALLED	1626	The function could not be executed."
	EndCase
	Case "1627"
		isFatalError "ERROR_FUNCTION_FAILED	1627	The function failed during execution."
	EndCase
	Case "1628"
		isFatalError "ERROR_INVALID_TABLE	1628	An invalid or unknown table was specified."
	EndCase
	Case "1629"
		isFatalError "ERROR_DATATYPE_MISMATCH	1629	The data supplied is the wrong type."
	EndCase
	Case "1630"
		isFatalError "ERROR_UNSUPPORTED_TYPE	1630	Data of this type is not supported."
	EndCase
	Case "1631"
		isFatalError "ERROR_CREATE_FAILED	1631	The Windows Installer service failed to start. Contact your support personnel."
	EndCase
	Case "1632"
		isFatalError "ERROR_INSTALL_TEMP_UNWRITABLE	1632	The Temp folder is either full or inaccessible. Verify that the Temp folder exists and that you can write to it."
	EndCase
	Case "1633"
		isFatalError "ERROR_INSTALL_PLATFORM_UNSUPPORTED	1633	This installation package is not supported on this platform. Contact your application vendor."
	EndCase
	Case "1634"
		isFatalError "ERROR_INSTALL_NOTUSED	1634	Component is not used on this machine."
	EndCase
	Case "1635"
		isFatalError "ERROR_PATCH_PACKAGE_OPEN_FAILED	1635	This patch package could not be opened. Verify that the patch package exists and is accessible, or contact the application vendor to verify that this is a valid Windows Installer patch package."
	EndCase
	Case "1636"
		isFatalError "ERROR_PATCH_PACKAGE_INVALID	1636	This patch package could not be opened. Contact the application vendor to verify that this is a valid Windows Installer patch package."
	EndCase
	Case "1637"
		isFatalError "ERROR_PATCH_PACKAGE_UNSUPPORTED	1637	This patch package cannot be processed by the Windows Installer service. You must install a Windows service pack that contains a newer version of the Windows Installer service."
	EndCase
	Case "1638"
		isFatalError "ERROR_PRODUCT_VERSION	1638	Another version of this product is already installed. Installation of this version cannot continue. To configure or remove the existing version of this product, use Add/Remove Programs in Control Panel."
	EndCase
	Case "1639"
		isFatalError "ERROR_INVALID_COMMAND_LINE	1639	Invalid command line argument. Consult the Windows Installer SDK for detailed command-line help."
	EndCase
	Case "1640"
		isFatalError "ERROR_INSTALL_REMOTE_DISALLOWED	1640	The current user is not permitted to perform installations from a client session of a server running the Terminal Server role service."
	EndCase
	Case "1641"
		comment "ERROR_SUCCESS_REBOOT_INITIATED	1641	The installer has initiated a restart. This message is indicative of a success."
		set $RebootStatus$ = "1"
	EndCase
	Case "1642"
		isFatalError "ERROR_PATCH_TARGET_NOT_FOUND	1642	The installer cannot install the upgrade patch because the program being upgraded may be missing or the upgrade patch updates a different version of the program. Verify that the program to be upgraded exists on your computer and that you have the correct upgrade patch."
	EndCase
	Case "1643"
		isFatalError "ERROR_PATCH_PACKAGE_REJECTED	1643	The patch package is not permitted by system policy."
	EndCase
	Case "1644"
		isFatalError "ERROR_INSTALL_TRANSFORM_REJECTED	1644	One or more customizations are not permitted by system policy."
	EndCase
	Case "1645"
		isFatalError "ERROR_INSTALL_REMOTE_PROHIBITED	1645	Windows Installer does not permit installation from a Remote Desktop Connection."
	EndCase
	Case "1646"
		isFatalError "ERROR_PATCH_REMOVAL_UNSUPPORTED	1646	The patch package is not a removable patch package."
	EndCase
	Case "1647"
		isFatalError "ERROR_UNKNOWN_PATCH	1647	The patch is not applied to this product."
	EndCase
	Case "1648"
		isFatalError "ERROR_PATCH_NO_SEQUENCE	1648	No valid sequence could be found for the set of patches."
	EndCase
	Case "1649"
		isFatalError "ERROR_PATCH_REMOVAL_DISALLOWED	1649	Patch removal was disallowed by policy."
	EndCase
	Case "1650"
		isFatalError "ERROR_INVALID_PATCH_XML	1650	The XML patch data is invalid."
	EndCase
	Case "1651"
		isFatalError "ERROR_PATCH_MANAGED_ADVERTISED_PRODUCT 	1651	Administrative user failed to apply patch for a per-user managed or a per-machine application that is in advertise state."
	EndCase
	Case "1652"
		isFatalError "ERROR_INSTALL_SERVICE_SAFEBOOT 	1652	Windows Installer is not accessible when the computer is in Safe Mode. Exit Safe Mode and try again or try using System Restore to return your computer to a previous state."
	EndCase
	Case "1653"
		isFatalError "ERROR_ROLLBACK_DISABLED 	1653	Could not perform a multiple-package transaction because rollback has been disabled. Multiple-Package Installations cannot run if rollback is disabled."
	EndCase
	Case "1654"
		isFatalError "ERROR_INSTALL_REJECTED	1654	The app that you are trying to run is not supported on this version of Windows. A Windows Installer package, patch, or transform that has not been signed by Microsoft cannot be installed on an ARM computer."
	EndCase
	Case "3010"
		comment "ERROR_SUCCESS_REBOOT_REQUIRED	3010	A restart is required to complete the install. This message is indicative of a success. This does not include installs where the ForceReboot action is run."
		set $RebootStatus$ = "1"
	EndCase
	DefaultCase
		isFatalError "Fatal error: Setup program gives an unknown exitcode: "+ $ExitCode$
	EndCase
EndSwitch
Of course you need to handle $RebootStatus$ in the main file, but this might be more flexible than using "ExitWindows /Reboot".

I sometimes also have problems with 1618, because some installation is 'still running', which is almost never the case. I could put a "taskkill msiexec.exe" in there, and try again. I'm not sure if this will fix it.
Bitte schreiben Sie Deutsch, when I'm responding in the German-speaking part of the forum!
Benutzeravatar
ueluekmen
uib-Team
Beiträge: 1940
Registriert: 28 Mai 2008, 10:53

Re: exit codes

Beitrag von ueluekmen »

Looks great with the new switch-case model ;)

I'm not sure, if it is a good idea to declare your variables in the includefile, if you declare these in the main file, you have only the sub-section in this file and then you can use append instead of insert. Second, I would change RebootStatus in RebootRequired. I would say this will make more sense.

But the idea to say, make these available in general is not bad. The Question here is, how we will make this? Should this be build-In in opsi-script or should be this a part of our opsi-template. I don't know at the moment. I will talk about this in one of the next dev-meetings.


Vielen Dank für die Nutzung von opsi. Im Forum ist unser Support begrenzt.

Für den professionellen Einsatz und individuelle Beratung empfehlen wir einen Support-Vertrag und eine Schulung.
Gerne informieren wir Sie zu unserem Angebot.

uib GmbH
Telefon: +49 6131 27561 0
E-Mail: sales@uib.de


Benutzeravatar
SisterOfMercy
Beiträge: 1556
Registriert: 22 Jun 2012, 19:18

Re: exit codes

Beitrag von SisterOfMercy »

I would put it here: c:\Program Files (x86)\opsi.org\opsi-client-agent\opsi-winst\lib\
There are also other scripts over there, which can be inserted or appended.

There is also a file called insert_check_exit_code.opsiinc there which contains this:

Code: Alles auswählen

; opsi include file

DefVar $ExitCode$

include_append "section_sub_check_exit_code.opsiinc"
And that one is called from setup_short32.opsiscript from the use_include directory in the template.

Code: Alles auswählen

[Actions]
requiredWinstVersion >= "4.11.4.6"
ScriptErrorMessages=off

include_append "section_sub_check_exitcode.opsiinc"
include_append "section_sub_get_licensekey.opsiinc"

DefVar $MsiId$
DefVar $UninstallProgram$
I'm not sure what the logic is for using that small extra file.

I was going to make multiple files for MSI and NSIS, for example. However, there are not many exit codes for NSIS, I can't seem to find a list :-(
There have been a few times where I got a weird error code with NSIS, something with UAC.

And this error code list is just something from the recent manual/template with a few extra exit codes, so it's basically something you made yourself ;)
Bitte schreiben Sie Deutsch, when I'm responding in the German-speaking part of the forum!
Benutzeravatar
ngbr
Ex-uib-Team
Beiträge: 130
Registriert: 27 Sep 2010, 11:41

Re: exit codes

Beitrag von ngbr »

Hi SisterOfMercy,

the include_append and include_insert statements are quite useful.
You just have to use them right.

include_append appends the given file behind the very last line of your script.
Most of the time you would want to include_insert , so that you can avoid duplicate code.

Be careful: there are no separate name - spaces yet - so you cant have duplicate $ExitCode$ .
The log will tell you if you try to define a second time because you include "section_sub_check_exit_code.opsiinc"

BTW: if you want a ready-made exit-code checker, try using opsi-setup-detector . its installable from our opsi-repository .

have fun!
---
hoping to help :)

if your problem was solved, pls mark this thread as 'SOLVED'. thank you .

-- no PN support --

Andre
Antworten