GetRegistryStringValue

Antworten
Nuern
Beiträge: 5
Registriert: 18 Mai 2011, 13:42

GetRegistryStringValue

Beitrag von Nuern »

Moin zusammen,

es ergibt sich folgende Schwierigkeit:

Bei dem Versuch den Adobe Reader 10.0.1 zu deinstallieren scheint das Auslesen der Registry nicht ganz hinzuhauen (nach meiner derzeitigen Auffassungsgabe).

Code: Alles auswählen

; Copyright (c) uib gmbh (www.uib.de)
; This sourcecode is owned by uib gmbh
; and published under the Terms of the General Public License.
; credits: http://www.opsi.org/credits/

DefVar $MsiId$

Message "Deinstalliere Adobe Reader 10 ..."

; Acrobat Reader 10.0 - DEU
Set $MsiId$ = '{AC76BA86-7AD7-1033-7B44-AA0000000001}'
if not (GetRegistryStringValue("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $MsiId$ + "] DisplayName") = "")
	comment "MSI id " + $MsiId$ + " found in registry, starting msiexec to uninstall"
	Winbatch_uninstall_msi
	sub_check_exitcode
endif


[Winbatch_uninstall_msi]
msiexec /x $MsiId$ /qb! REBOOT=ReallySuppress "$LogDir$\$ProductId$.delete-adobereader-x-log.txt"

[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
Was der Testlauf mit winst32.exe ergibt ist Folgendes:

Code: Alles auswählen

[1] [20.05.2011 09:08:28] opsi-winst 4.10.8.15 started at 20.05.2011 08:53:41
[1] [20.05.2011 09:08:28] 
[1] [20.05.2011 09:08:28] ============ Version 4.10.8.15 WIN32 script "C:\tmp\adobereader-x\delsub.ins"
[1] [20.05.2011 09:08:28]              start: 2011-05-20  09:08:28 
[1] [20.05.2011 09:08:28]              on client named    "PCMZ41"
[1] [20.05.2011 09:08:28]              user account    "Administrator"
[1] [20.05.2011 09:08:28] [executing: "C:\Program Files\opsi.org\opsi-client-agent\opsi-winst\winst32.exe"]
[1] [20.05.2011 09:08:28] system infos:
[1] [20.05.2011 09:08:28] 00:1B:FC:FB:E2:D8  -  PC hardware address
[1] [20.05.2011 09:08:28] PCMZ41.ver.local  -  IP name 
[1] [20.05.2011 09:08:28] 192.168.42.32  -  IP address
[1] [20.05.2011 09:08:28] DEU  -  System default locale 
[1] [20.05.2011 09:08:28] 
[6] [20.05.2011 09:08:28] Registry key [HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion]  opened
[6] [20.05.2011 09:08:28] Key closed
[1] [20.05.2011 09:08:28] ___________________
[1] [20.05.2011 09:08:28] script finished
[1] [20.05.2011 09:08:28] 0 errors
[1] [20.05.2011 09:08:28] 0 warnings
[1] [20.05.2011 09:08:28] 
[1] [20.05.2011 09:08:28] 
[6] [20.05.2011 09:08:28] Delete "c:\tmp\_winstbat_*"
[6] [20.05.2011 09:08:28]   Search "c:\tmp\"
Hat jemand einen Rat oder sogar ein fertiges Skript für die Deinstallation von Adobe Reader X ?

Vielen Dank und Gruß,
Maddin
karni
Beiträge: 193
Registriert: 08 Okt 2009, 14:07

Re: GetRegistryStringValue

Beitrag von karni »

Wieso so kompliziert mit variablen??
if ist nicht richtig

Code: Alles auswählen

; Copyright (c) uib gmbh (www.uib.de)
; This sourcecode is owned by uib gmbh
; and published under the Terms of the General Public License.
; credits: http://www.opsi.org/credits/

Message "Deinstalliere Adobe Reader 10 ..."

; Acrobat Reader 10.0 - DEU
if (GetRegistryStringValue("[HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{AC76BA86-7AD7-1033-7B44-AA0000000001}]"+"DisplayName") = "Adobe Reader X")
   comment "Adobe Reader X" found in registry, starting msiexec to uninstall"
   Winbatch_uninstall_msi
   sub_check_exitcode
endif

[Winbatch_uninstall_msi]
msiexec /x {AC76BA86-7AD7-1033-7B44-AA0000000001} /qb! REBOOT=ReallySuppress "$LogDir$\$ProductId$.delete-adobereader-x-log.txt"

[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
bell
Beiträge: 41
Registriert: 22 Dez 2010, 12:46

Re: GetRegistryStringValue

Beitrag von bell »

Hallo,

Müsste eigentlich funktionieren, schon mal geguckt ob es den Registryeintrag überhaupt gibt bzw die MSI ID die richtige ist?

Ansonsten vielleicht mal:

Code: Alles auswählen

DefVar $MsiId$

Message "Deinstalliere Adobe Reader 10 ..."

; Acrobat Reader 10.0 - DEU
Set $MsiId$ = '{AC76BA86-7AD7-1033-7B44-AA0000000001}'
if not (GetRegistryStringValue("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $MsiId$ + "] DisplayName") = "")
   comment "MSI id " + $MsiId$ + " found in registry, starting msiexec to uninstall"
   Winbatch_uninstall_msi
   sub_check_exitcode
else
 comment "MSI id " + $MsiId$ + " not found in registry.
endif
Zur Fehleranalyse.

MfG bell
Nuern
Beiträge: 5
Registriert: 18 Mai 2011, 13:42

Re: GetRegistryStringValue

Beitrag von Nuern »

:oops: peinlich, peinlich.
Warum das Skript nicht ordentlich lief?

Der Bereich [Actions] war nicht festgelegt, sprich [Actions] in der ersten Zeile fehlte ...

Sowas passiert einem aber auch nur einmal.

Danke trotzdem für Eure Hilfe.

*EDIT*
so läuft die Kiste nun wie sie soll

Code: Alles auswählen

[Actions]
DefVar $MsiId$
DefVar $regKey$
DefVar $ExitCode$

Message "Deinstalliere Adobe Reader 10 ..."

Set $regKey$ = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
Set $MsiId$ = "{AC76BA86-7AD7-1031-7B44-AA0000000001}"

if not (GetRegistryStringValue("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{AC76BA86-7AD7-1031-7B44-AA0000000001}] DisplayName") = "")
;if not (GetRegistryStringValue("[" + $regKey$ + $MsiId$ + "] DisplayName") = "")
   comment "MSI id " + $MsiId$ + " found in registry, starting msiexec to uninstall"
   Winbatch_uninstall_msi
else
comment "MSI id " + $MsiId$ + " not found in registry.
endif


[Winbatch_uninstall_msi] 
msiexec /x $MsiId$ /qb! REBOOT=ReallySuppress
Antworten