VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Installer/VBoxGuestAdditionsUninstallOld.nsh@ 33280

Last change on this file since 33280 was 31634, checked in by vboxsync, 14 years ago

Windows Additions: export shared folders and installer to OSE

File size: 10.5 KB
Line 
1
2!macro Uninstall_RunExtUnInstaller un
3Function ${un}Uninstall_RunExtUnInstaller
4
5 Pop $0
6 Push $1
7 Push $2
8
9 ; Try to run the current uninstaller
10 StrCpy $1 "$0\uninst.exe"
11 IfFileExists "$1" run 0
12 MessageBox MB_OK "VirtualBox Guest Additions uninstaller not found! Path = $1" /SD IDOK
13 StrCpy $0 1 ; Tell the caller that we were not able to start the uninstaller
14 Goto exit
15
16run:
17
18 ; Always try to run in silent mode
19 Goto run_uninst_silent
20
21run_uninst_silent:
22
23 ExecWait '"$1" /S _?=$0' $2 ; Silently run uninst.exe in it's dir and don't copy it to a temp. location
24 Goto handle_result
25
26run_uninst:
27
28 ExecWait '"$1" _?=$0' $2 ; Run uninst.exe in it's dir and don't copy it to a temp. location
29 Goto handle_result
30
31handle_result:
32
33 ; Note that here a race might going on after the user clicked on
34 ; "Reboot now" in the installer ran above and this installer cleaning
35 ; up aftwards.
36
37 ; ... so try to abort the current reboot / shutdown caused by the installer ran before
38 Call ${un}AbortShutdown
39
40;!ifdef _DEBUG
41; MessageBox MB_OK 'Debug Message: Uninstaller was called, result is: $2' /SD IDOK
42;!endif
43
44 ${Switch} $2 ; Check exit codes
45 ${Case} 1 ; Aborted by user
46 StrCpy $0 1 ; Tell the caller that we were aborted by the user
47 ${Break}
48 ${Case} 2 ; Aborted by script (that might be okay)
49 StrCpy $0 0 ; All went well
50 ${Break}
51 ${Default} ; Normal exixt
52 StrCpy $0 0 ; All went well
53 ${Break}
54 ${EndSwitch}
55 Goto exit
56
57exit:
58
59 Pop $2
60 Pop $1
61 Push $0
62
63FunctionEnd
64!macroend
65!insertmacro Uninstall_RunExtUnInstaller ""
66!insertmacro Uninstall_RunExtUnInstaller "un."
67
68!macro Uninstall_WipeInstallationDirectory un
69Function ${un}Uninstall_WipeInstallationDirectory
70
71 Pop $0
72 Push $1
73 Push $2
74
75 ; Do some basic sanity checks for not screwing up too fatal ...
76 DetailPrint "Removing old installation directory ($0) ..."
77 ${If} $0 != $PROGRAMFILES
78 ${AndIf} $0 != $PROGRAMFILES32
79 ${AndIf} $0 != $PROGRAMFILES64
80 ${AndIf} $0 != $COMMONFILES32
81 ${AndIf} $0 != $COMMONFILES64
82 ${AndIf} $0 != $WINDIR
83 ${AndIf} $0 != $SYSDIR
84 DetailPrint "Wiping ($0) ..."
85 Goto wipe
86 ${EndIf}
87 Goto wipe_abort
88
89wipe:
90
91 RMDir /r /REBOOTOK "$0"
92 StrCpy $0 0 ; All went well
93 Goto exit
94
95wipe_abort:
96
97 DetailPrint "Won't remove directory ($0)!"
98 StrCpy $0 1 ; Signal some failure
99 Goto exit
100
101exit:
102
103 Pop $2
104 Pop $1
105 Push $0
106
107FunctionEnd
108!macroend
109!insertmacro Uninstall_WipeInstallationDirectory ""
110!insertmacro Uninstall_WipeInstallationDirectory "un."
111
112; This function cleans up an old Sun installation
113!macro Uninstall_Sun un
114Function ${un}Uninstall_Sun
115
116 Push $0
117 Push $1
118 Push $2
119
120 ; Get current installation path
121 ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Sun VirtualBox Guest Additions" "UninstallString"
122 StrCmp $0 "" exit
123
124 ; Extract path
125 Push "$0" ; String
126 Push "\" ; SubString
127 Push "<" ; SearchDirection
128 Push "<" ; StrInclusionDirection
129 Push "0" ; IncludeSubString
130 Push "0" ; Loops
131 Push "0" ; CaseSensitive
132 Call ${un}StrStrAdv
133 Pop $1 ; $1 only contains the full path
134
135 StrCmp $1 "" exit
136
137 ; Save current i8042prt info to new uninstall registry path
138 ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Sun VirtualBox Guest Additions" ${ORG_MOUSE_PATH}
139 WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" ${ORG_MOUSE_PATH} $0
140
141 ; Try to wipe current installation directory
142 Push $1 ; Push uninstaller path to stack
143 Call ${un}Uninstall_WipeInstallationDirectory
144 Pop $2 ; Get uninstaller exit code from stack
145 StrCmp $2 0 common exit ; Only process common part if exit code is 0, otherwise exit
146
147common:
148
149 ; Make sure everything is cleaned up in case the old uninstaller did forget something
150 DeleteRegKey HKLM "SOFTWARE\Sun\VirtualBox Guest Additions"
151 DeleteRegKey /ifempty HKLM "SOFTWARE\Sun"
152 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Sun VirtualBox Guest Additions"
153 Delete /REBOOTOK "$1\netamd.inf"
154 Delete /REBOOTOK "$1\pcntpci5.cat"
155 Delete /REBOOTOK "$1\PCNTPCI5.sys"
156
157 ; Try to remove old installation directory if empty
158 RMDir /r /REBOOTOK "$SMPROGRAMS\Sun VirtualBox Guest Additions"
159 RMDir /REBOOTOK "$1"
160
161 ; Get original mouse driver info and restore it
162 ;ReadRegStr $0 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" ${ORG_MOUSE_PATH}
163 ;WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\i8042prt" "ImagePath" $0
164 ;Delete "$SYSDIR\drivers\VBoxMouseNT.sys"
165
166 ; Delete vendor installation directory (only if completely empty)
167!if $%BUILD_TARGET_ARCH% == "x86" ; 32-bit
168 RMDir /REBOOTOK "$PROGRAMFILES32\Sun"
169!else ; 64-bit
170 RMDir /REBOOTOK "$PROGRAMFILES64\Sun"
171!endif
172
173exit:
174
175 Pop $2
176 Pop $1
177 Pop $0
178
179FunctionEnd
180!macroend
181!insertmacro Uninstall_Sun ""
182!insertmacro Uninstall_Sun "un."
183
184; This function cleans up an old xVM Sun installation
185!macro Uninstall_SunXVM un
186Function ${un}Uninstall_SunXVM
187
188 Push $0
189 Push $1
190 Push $2
191
192 ; Get current installation path
193 ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Sun xVM VirtualBox Guest Additions" "UninstallString"
194 StrCmp $0 "" exit
195
196 ; Extract path
197 Push "$0" ; String
198 Push "\" ; SubString
199 Push "<" ; SearchDirection
200 Push "<" ; StrInclusionDirection
201 Push "0" ; IncludeSubString
202 Push "0" ; Loops
203 Push "0" ; CaseSensitive
204 Call ${un}StrStrAdv
205 Pop $1 ; $1 only contains the full path
206
207 StrCmp $1 "" exit
208
209 ; Save current i8042prt info to new uninstall registry path
210 ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Sun xVM VirtualBox Guest Additions" ${ORG_MOUSE_PATH}
211 WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" ${ORG_MOUSE_PATH} $0
212
213 ; Try to wipe current installation directory
214 Push $1 ; Push uninstaller path to stack
215 Call ${un}Uninstall_WipeInstallationDirectory
216 Pop $2 ; Get uninstaller exit code from stack
217 StrCmp $2 0 common exit ; Only process common part if exit code is 0, otherwise exit
218
219common:
220
221 ; Make sure everything is cleaned up in case the old uninstaller did forget something
222 DeleteRegKey HKLM "SOFTWARE\Sun\xVM VirtualBox Guest Additions"
223 DeleteRegKey /ifempty HKLM "SOFTWARE\Sun"
224 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Sun xVM VirtualBox Guest Additions"
225 Delete /REBOOTOK "$1\netamd.inf"
226 Delete /REBOOTOK "$1\pcntpci5.cat"
227 Delete /REBOOTOK "$1\PCNTPCI5.sys"
228
229 ; Try to remove old installation directory if empty
230 RMDir /r /REBOOTOK "$SMPROGRAMS\Sun xVM VirtualBox Guest Additions"
231 RMDir /REBOOTOK "$1"
232
233 ; Delete vendor installation directory (only if completely empty)
234!if $%BUILD_TARGET_ARCH% == "x86" ; 32-bit
235 RMDir /REBOOTOK "$PROGRAMFILES32\Sun"
236!else ; 64-bit
237 RMDir /REBOOTOK "$PROGRAMFILES64\Sun"
238!endif
239
240 ; Get original mouse driver info and restore it
241 ;ReadRegStr $0 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" ${ORG_MOUSE_PATH}
242 ;WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\i8042prt" "ImagePath" $0
243 ;Delete "$SYSDIR\drivers\VBoxMouseNT.sys"
244
245exit:
246
247 Pop $2
248 Pop $1
249 Pop $0
250
251FunctionEnd
252!macroend
253!insertmacro Uninstall_SunXVM ""
254!insertmacro Uninstall_SunXVM "un."
255
256; This function cleans up an old innotek installation.
257!macro Uninstall_Innotek un
258Function ${un}Uninstall_Innotek
259
260 Push $0
261 Push $1
262 Push $2
263
264 ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\innotek VirtualBox Guest Additions" "UninstallString"
265 StrCmp $0 "" exit
266
267 ; Extract path
268 Push "$0" ; String
269 Push "\" ; SubString
270 Push "<" ; SearchDirection
271 Push "<" ; StrInclusionDirection
272 Push "0" ; IncludeSubString
273 Push "0" ; Loops
274 Push "0" ; CaseSensitive
275 Call ${un}StrStrAdv
276 Pop $1 ; $1 only contains the full path
277
278 StrCmp $1 "" exit
279
280 ; Save current i8042prt info to new uninstall registry path
281 ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\innotek VirtualBox Guest Additions" ${ORG_MOUSE_PATH}
282 WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" ${ORG_MOUSE_PATH} $0
283
284 ; Try to wipe current installation directory
285 Push $1 ; Push uninstaller path to stack
286 Call ${un}Uninstall_WipeInstallationDirectory
287 Pop $2 ; Get uninstaller exit code from stack
288 StrCmp $2 0 common exit ; Only process common part if exit code is 0, otherwise exit
289
290common:
291
292 ; Remove left over files which were not entirely catched by the formerly running
293 ; uninstaller
294 DeleteRegKey HKLM "SOFTWARE\innotek\VirtualBox Guest Additions"
295 DeleteRegKey HKLM "SOFTWARE\innotek"
296 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\innotek VirtualBox Guest Additions"
297 Delete /REBOOTOK "$1\VBoxGuestDrvInst.exe"
298 Delete /REBOOTOK "$1\VBoxMouseInst.exe"
299 Delete /REBOOTOK "$1\VBoxSFDrvInst.exe"
300 Delete /REBOOTOK "$1\RegCleanup.exe"
301 Delete /REBOOTOK "$1\VBoxService.exe"
302 Delete /REBOOTOK "$1\VBoxMouseInst.exe"
303 Delete /REBOOTOK "$1\innotek VirtualBox Guest Additions.url"
304 Delete /REBOOTOK "$1\uninst.exe"
305 Delete /REBOOTOK "$1\iexplore.ico"
306 Delete /REBOOTOK "$1\install.log"
307 Delete /REBOOTOK "$1\VBCoInst.dll"
308 Delete /REBOOTOK "$1\VBoxControl.exe"
309 Delete /REBOOTOK "$1\VBoxDisp.dll"
310 Delete /REBOOTOK "$1\VBoxGINA.dll"
311 Delete /REBOOTOK "$1\VBoxGuest.cat"
312 Delete /REBOOTOK "$1\VBoxGuest.inf"
313 Delete /REBOOTOK "$1\VBoxGuest.sys"
314 Delete /REBOOTOK "$1\VBoxMouse.inf"
315 Delete /REBOOTOK "$1\VBoxMouse.sys"
316 Delete /REBOOTOK "$1\VBoxVideo.cat"
317 Delete /REBOOTOK "$1\VBoxVideo.inf"
318 Delete /REBOOTOK "$1\VBoxVideo.sys"
319
320 ; Try to remove old installation directory if empty
321 RMDir /r /REBOOTOK "$SMPROGRAMS\innotek VirtualBox Guest Additions"
322 RMDir /REBOOTOK "$1"
323
324 ; Delete vendor installation directory (only if completely empty)
325!if $%BUILD_TARGET_ARCH% == "x86" ; 32-bit
326 RMDir /REBOOTOK "$PROGRAMFILES32\innotek"
327!else ; 64-bit
328 RMDir /REBOOTOK "$PROGRAMFILES64\innotek"
329!endif
330
331 ; Get original mouse driver info and restore it
332 ;ReadRegStr $0 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" ${ORG_MOUSE_PATH}
333 ;WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\i8042prt" "ImagePath" $0
334 ;Delete "$SYSDIR\drivers\VBoxMouseNT.sys"
335
336exit:
337
338 Pop $2
339 Pop $1
340 Pop $0
341
342FunctionEnd
343!macroend
344!insertmacro Uninstall_Innotek ""
345!insertmacro Uninstall_Innotek "un."
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette