Code

source: opsi.opsi-builder/sample/All/CLIENT_DATA/delsub3264.opsiscript @ 90844b

Revision 90844b, 9.3 KB checked in by geos_one, 2 months ago (diff)

File Assoc Unregister

  • Property mode set to 100644
Line 
1; Copyright (c) uib gmbh (www.uib.de)
2; This sourcecode is owned by uib gmbh
3; and published under the Terms of the General Public License.
4; credits: http://www.opsi.org/en/credits/
5
6include_append "browserkill.opsiinc"
7
8Set $UninstallProgram32$ = $InstallDir32$ + "\" + $UninstallExecutable32$
9Set $IniFile32$ = $InstallDir32$ + "\opsi-" + $ProductId$ + ".ini"
10
11Set $UninstallProgram64$ = $InstallDir64$ + "\" + $UninstallExecutable64$
12Set $IniFile64$ = $InstallDir64$ + "\opsi-" + $ProductId$ + ".ini"
13
14if (($INST_SystemType$ = "x86 System") and ($INST_architecture$ = "system specific")) or ($INST_architecture$ = "both") or ($INST_architecture$ = "32 only")
15        if FileExists($IniFile32$)
16                Set $OLD_VERSION$ = GetValueFromInifile($IniFile32$,"COMMON","VERSION","")
17                Set $OLD_CREATOR_TAG$ = GetValueFromInifile($IniFile32$,"COMMON","CREATOR_TAG","")
18                Set $OLD_RELEASE$ = GetValueFromInifile($IniFile32$,"COMMON","RELEASE","")
19                Message "Uninstalling " + $ProductId$ + " "+ $OLD_VERSION$ + "-" + $OLD_CREATOR_TAG$ + $OLD_RELEASE$ + " 32 Bit..."
20        else
21                Message "Uninstalling " + $ProductId$ + " 32 Bit..."
22        endif
23
24        if FileExists($IniFile32$)
25                Set $UninstallExecutable32$ = GetValueFromInifile($IniFile32$,"X86","UninstallExecutable32","XXXXXXXX.exe")
26                Set $UninstallProgramOld32$ = $InstallDir32$ + "\" + $UninstallExecutable32$
27                if FileExists($UninstallProgramOld32$)
28                        comment "Uninstall program found, starting uninstall"
29                        Winbatch_uninstall_old_32
30                        sub_check_exitcode
31                endif
32        endif
33        if FileExists($UninstallProgram32$)
34                comment "Uninstall program found, starting uninstall"
35                Winbatch_uninstall_32
36                sub_check_exitcode
37        endif
38
39        if FileExists($IniFile32$)
40                Set $MsiIdOld32$ = GetValueFromInifile($IniFile32$,"X86","MsiId32","{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}")
41                if not (GetRegistryStringValue32("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $MsiIdOld32$ + "] DisplayName") = "")
42                        comment "Old MSI id " + $MsiIdOld32$ + " found in registry, starting msiexec to uninstall old version"
43                        Winbatch_uninstall_msi_old_32
44                        sub_check_exitcode
45                endif
46        endif
47        if not (GetRegistryStringValue32("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $MsiId32$ + "] DisplayName") = "")
48                comment "MSI id " + $MsiId32$ + " found in registry, starting msiexec to uninstall"
49                Winbatch_uninstall_msi_32
50                sub_check_exitcode
51        endif
52       
53        ;comment "Kill Web Browser"
54        ;ExecWith_BrowserKill %System%\cscript.exe //b //nologo
55        comment "Delete files"
56        Files_uninstall_32 /32Bit
57        comment "Cleanup registry"
58        Registry_uninstall /32Bit
59        comment "File Type Association"
60        DosInAnIcon_FileTypeAssoc_uninstall
61endif
62
63if ($INST_SystemType$ = "64 Bit System") and (($INST_architecture$ = "system specific") or ($INST_architecture$ = "both") or ($INST_architecture$ = "64 only"))
64        if FileExists($IniFile64$)
65                Set $OLD_VERSION$ = GetValueFromInifile($IniFile64$,"COMMON","VERSION","")
66                Set $OLD_CREATOR_TAG$ = GetValueFromInifile($IniFile64$,"COMMON","CREATOR_TAG","")
67                Set $OLD_RELEASE$ = GetValueFromInifile($IniFile64$,"COMMON","RELEASE","")
68                Message "Uninstalling " + $ProductId$ + " "+ $OLD_VERSION$ + "-" + $OLD_CREATOR_TAG$ + $OLD_RELEASE$ + " 64 Bit..."
69        else
70                Message "Uninstalling " + $ProductId$ + " 64 Bit..."
71        endif
72
73        if FileExists($IniFile64$)
74                Set $UninstallExecutable64$ = GetValueFromInifile($IniFile64$,"X86_64","UninstallExecutable64","XXXXXXXX.exe")
75                Set $UninstallProgramOld64$ = $InstallDir64$ + "\" + $UninstallExecutable64$
76                if FileExists($UninstallProgramOld64$)
77                        comment "Uninstall program found, starting uninstall"
78                        Winbatch_uninstall_old_64
79                        sub_check_exitcode
80                endif
81        endif
82        if FileExists($UninstallProgram64$)
83                comment "Uninstall program found, starting uninstall"
84                Winbatch_uninstall_64
85                sub_check_exitcode
86        endif
87
88        if FileExists($IniFile64$)
89                Set $MsiIdOld64$ = GetValueFromInifile($IniFile64$,"X86_64","MsiId64","{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}")
90                if not (GetRegistryStringValue64("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $MsiIdOld64$ + "] DisplayName") = "")
91                        comment "Old MSI id " + $MsiIdOld64$ + " found in registry, starting msiexec to uninstall old version"
92                        Winbatch_uninstall_msi_old_64
93                        sub_check_exitcode
94                endif
95        endif
96        if not (GetRegistryStringValue64("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $MsiId64$ + "] DisplayName") = "")
97                comment "MSI id " + $MsiId64$ + " found in registry, starting msiexec to uninstall"
98                Winbatch_uninstall_msi_64
99                sub_check_exitcode
100        endif
101       
102        ;comment "Kill Web Browser"
103        ;ExecWith_BrowserKill %System%\cscript.exe //b //nologo
104        comment "Delete files"
105        Files_uninstall_64 /64Bit
106        comment "Cleanup registry"
107        Registry_uninstall /64Bit
108        comment "File Type Association"
109        DosInAnIcon_FileTypeAssoc_uninstall
110endif
111
112comment "Delete program shortcuts"
113LinkFolder_uninstall
114
115if $Reboot$="1"
116        ExitWindows /ImmediateReboot
117endif
118
119[Winbatch_uninstall_old_32]
120; Choose one of the following examples as basis for program uninstall
121;
122; === Nullsoft Scriptable Install System ================================================================
123; maby better Call as
124; Winbatch_uninstall /WaitforProcessending "Au_.exe" /Timeoutseconds 10
125; "$UninstallProgramOld32$" /S
126;
127; === Inno Setup ========================================================================================
128; "$UninstallProgramOld32$" /silent /norestart /SUPPRESSMSGBOXES /nocancel
129
130[Winbatch_uninstall_32]
131; Choose one of the following examples as basis for program uninstall
132;
133; === Nullsoft Scriptable Install System ================================================================
134; maby better Call as
135; Winbatch_uninstall /WaitforProcessending "Au_.exe" /Timeoutseconds 10
136; "$UninstallProgram32$" /S
137;
138; === Inno Setup ========================================================================================
139; "$UninstallProgram32$" /silent /norestart /SUPPRESSMSGBOXES /nocancel
140
141
142[Winbatch_uninstall_msi_old_32]
143msiexec /x $MsiIdOld32$ /qb-! REBOOT=ReallySuppress
144
145[Winbatch_uninstall_msi_32]
146msiexec /x $MsiId32$ /qb-! REBOOT=ReallySuppress
147
148[Files_uninstall_32]
149; Example for recursively deleting the installation directory (don't forget the trailing backslash):
150;
151; delete -sf "$InstallDir32$\"
152
153[Winbatch_uninstall_old_64]
154; Choose one of the following examples as basis for program uninstall
155;
156; === Nullsoft Scriptable Install System ================================================================
157; maby better Call as
158; Winbatch_uninstall /WaitforProcessending "Au_.exe" /Timeoutseconds 10
159; "$UninstallProgramOld64$" /S
160;
161; === Inno Setup ========================================================================================
162; "$UninstallProgramOld64$" /silent /norestart /SUPPRESSMSGBOXES /nocancel
163
164[Winbatch_uninstall_64]
165; Choose one of the following examples as basis for program uninstall
166;
167; === Nullsoft Scriptable Install System ================================================================
168; maby better Call as
169; Winbatch_uninstall /WaitforProcessending "Au_.exe" /Timeoutseconds 10
170; "$UninstallProgram64$" /S
171;
172; === Inno Setup ========================================================================================
173; "$UninstallProgram64$" /silent /norestart /SUPPRESSMSGBOXES /nocancel
174
175[Winbatch_uninstall_msi_old_64]
176msiexec /x $MsiIdOld64$ /qb-! REBOOT=ReallySuppress
177
178[Winbatch_uninstall_msi_64]
179msiexec /x $MsiId64$ /qb-! REBOOT=ReallySuppress
180
181[Files_uninstall_64]
182; Example for recursively deleting the installation directory:
183;
184; del -sf "$InstallDir64$\"
185
186[Registry_uninstall]
187; Example of deleting a registry key:
188;
189; deletekey [HKEY_LOCAL_MACHINE\Software\$ProductId$]
190
191[LinkFolder_uninstall]
192; Example of deleting a folder from AllUsers startmenu:
193;
194; set_basefolder common_programs
195; delete_subfolder $ProductId$
196;
197; Example of deleting a shortcut from AllUsers desktop:
198;
199; set_basefolder common_desktopdirectory
200; set_subfolder ""
201; delete_element $ProductId$
202
203[DosInAnIcon_FileTypeAssoc_uninstall]
204; Requires danysys.sfta
205; Sample Usage:
206; Set Acrobat Reader DC as Default .pdf reader:
207;
208; SFTA --unreg AcroExch.Document.DC .pdf
209;
210; Set Sumatra PDF as Default .pdf reader:
211;
212; SFTA --unreg Applications\SumatraPDF.exe .pdf
213
214[Sub_check_exitcode]
215comment "Test for installation success via exit code"
216set $ExitCode$ = getLastExitCode
217; informations to exit codes see
218; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
219; http://msdn.microsoft.com/en-us/library/aa368542.aspx
220if ($ExitCode$ = "0")
221        comment "Looks good: setup program gives exitcode zero"
222else
223        comment "Setup program gives a exitcode unequal zero: " + $ExitCode$
224        if ($ExitCode$ = "1605")
225                comment "ERROR_UNKNOWN_PRODUCT  1605    This action is only valid for products that are currently installed."
226                comment "Uninstall of a not installed product failed - no problem"
227        else
228                if ($ExitCode$ = "1641")
229                        comment "looks good: setup program gives exitcode 1641"
230                        comment "ERROR_SUCCESS_REBOOT_INITIATED 1641    The installer has initiated a restart. This message is indicative of a success."
231                else
232                        if ($ExitCode$ = "3010")
233                                comment "looks good: setup program gives exitcode 3010"
234                                comment "ERROR_SUCCESS_REBOOT_REQUIRED  3010    A restart is required to complete the install. This message is indicative of a success."
235                        else
236                                logError "Fatal: Setup program gives an unknown exitcode unequal zero: " + $ExitCode$
237                                isFatalError
238                        endif
239                endif
240        endif
241endif
242
Note: See TracBrowser for help on using the repository browser.