Code

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

Revision 90844b, 5.5 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 $UninstallProgram$ = $InstallDir$ + "\" + $UninstallExecutable$
9Set $IniFile$ = $InstallDir$ + "\opsi-" + $ProductId$ + ".ini"
10
11if FileExists($IniFile$)
12        Set $OLD_VERSION$ = GetValueFromInifile($IniFile$,"COMMON","VERSION","")
13        Set $OLD_CREATOR_TAG$ = GetValueFromInifile($IniFile$,"COMMON","CREATOR_TAG","")
14        Set $OLD_RELEASE$ = GetValueFromInifile($IniFile$,"COMMON","RELEASE","")
15        Message "Uninstalling " + $ProductId$ + " " + $OLD_VERSION$ + "-" + $OLD_CREATOR_TAG$ + $OLD_RELEASE$ + " ..."
16else
17        Message "Uninstalling " + $ProductId$ + " ..."
18endif
19
20if FileExists($IniFile$)
21        Set $UninstallExecutable$ = GetValueFromInifile($IniFile$,"X86","UninstallExecutable","XXXXXXXX.exe")
22        Set $UninstallProgramOld$ = $InstallDir$ + "\" + $UninstallExecutable$
23        if FileExists($UninstallProgramOld$)
24                comment "Uninstall program found, starting uninstall"
25                Winbatch_uninstall_old
26                sub_check_exitcode
27                ;set $Reboot$="1"
28        endif
29endif
30if FileExists($UninstallProgram$)
31        comment "Uninstall program found, starting uninstall"
32        Winbatch_uninstall
33        sub_check_exitcode
34        ;set $Reboot$="1"
35endif
36
37if FileExists($IniFile$)
38        Set $MsiIdOld$ = GetValueFromInifile($IniFile$,"X86","MsiId","{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}")
39        if not (GetRegistryStringValue32("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $MsiIdOld$ + "] DisplayName") = "")
40                comment "Old MSI id " + $MsiIdOld$ + " found in registry, starting msiexec to uninstall old version"
41                Winbatch_uninstall_msi_old
42                sub_check_exitcode
43                ;set $Reboot$="1"
44        endif
45endif
46if not (GetRegistryStringValue32("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $MsiId$ + "] DisplayName") = "")
47        comment "MSI id " + $MsiId$ + " found in registry, starting msiexec to uninstall"
48        Winbatch_uninstall_msi
49        sub_check_exitcode
50        ;set $Reboot$="1"
51endif
52
53;comment "Kill Web Browser"
54;ExecWith_BrowserKill %System%\cscript.exe //b //nologo
55
56comment "Delete files"
57Files_uninstall /32Bit
58
59comment "Cleanup registry"
60Registry_uninstall /32Bit
61
62comment "Delete program shortcuts"
63LinkFolder_uninstall
64
65comment "File Type Association"
66DosInAnIcon_FileTypeAssoc_uninstall
67
68if $Reboot$="1"
69        ExitWindows /ImmediateReboot
70endif
71
72[Winbatch_uninstall_old]
73; Choose one of the following examples as basis for program uninstall
74;
75; === Nullsoft Scriptable Install System ================================================================
76; maybe better called as
77; Winbatch_uninstall_old /WaitforProcessending "Au_.exe" /Timeoutseconds 10
78; "$UninstallProgramOld$" /S
79;
80; === Inno Setup ========================================================================================
81; "$UninstallProgramOld$" /silent /norestart /SUPPRESSMSGBOXES /nocancel
82
83[Winbatch_uninstall]
84; Choose one of the following examples as basis for program uninstall
85;
86; === Nullsoft Scriptable Install System ================================================================
87; maybe better called as
88; Winbatch_uninstall /WaitforProcessending "Au_.exe" /Timeoutseconds 10
89; "$UninstallProgram$" /S
90;
91; === Inno Setup ========================================================================================
92; "$UninstallProgram$" /silent /norestart /SUPPRESSMSGBOXES /nocancel
93
94[Winbatch_uninstall_msi_old]
95msiexec /x $MsiIdOld$ /qb-! REBOOT=ReallySuppress
96
97[Winbatch_uninstall_msi]
98msiexec /x $MsiId$ /qb-! REBOOT=ReallySuppress
99
100[Files_uninstall]
101; Example for recursively deleting the installation directory:
102;
103; del -sf "$InstallDir$\"
104
105[Registry_uninstall]
106; Example of deleting a registry key:
107;
108; deletekey [HKEY_LOCAL_MACHINE\Software\$ProductId$]
109
110[LinkFolder_uninstall]
111; Example of deleting a folder from AllUsers startmenu:
112;
113; set_basefolder common_programs
114; delete_subfolder $ProductId$
115;
116; Example of deleting a shortcut from AllUsers desktop:
117;
118; set_basefolder common_desktopdirectory
119; set_subfolder ""
120; delete_element $ProductId$
121
122[DosInAnIcon_FileTypeAssoc_uninstall]
123; Requires danysys.sfta
124; Sample Usage:
125; Set Acrobat Reader DC as Default .pdf reader:
126;
127; SFTA --unreg AcroExch.Document.DC .pdf
128;
129; Set Sumatra PDF as Default .pdf reader:
130;
131; SFTA --unreg Applications\SumatraPDF.exe .pdf
132
133[Sub_check_exitcode]
134comment "Test for installation success via exit code"
135set $ExitCode$ = getLastExitCode
136; informations to exit codes see
137; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
138; http://msdn.microsoft.com/en-us/library/aa368542.aspx
139if ($ExitCode$ = "0")
140        comment "Looks good: setup program gives exitcode zero"
141else
142        comment "Setup program gives a exitcode unequal zero: " + $ExitCode$
143        if ($ExitCode$ = "1605")
144                comment "ERROR_UNKNOWN_PRODUCT  1605    This action is only valid for products that are currently installed."
145                comment "Uninstall of a not installed product failed - no problem"
146        else
147                if ($ExitCode$ = "1641")
148                        comment "looks good: setup program gives exitcode 1641"
149                        comment "ERROR_SUCCESS_REBOOT_INITIATED 1641    The installer has initiated a restart. This message is indicative of a success."
150                else
151                        if ($ExitCode$ = "3010")
152                                comment "looks good: setup program gives exitcode 3010"
153                                comment "ERROR_SUCCESS_REBOOT_REQUIRED  3010    A restart is required to complete the install. This message is indicative of a success."
154                        else
155                                logError "Fatal: Setup program gives an unknown exitcode unequal zero: " + $ExitCode$
156                                isFatalError
157                        endif
158                endif
159        endif
160endif
161
Note: See TracBrowser for help on using the repository browser.