VirtualBox

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

Last change on this file since 96693 was 96693, checked in by vboxsync, 21 months ago

Add/Nt/Installer: Reduce the number of warnings a little.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use