[69354] | 1 | ; $Id: VBoxGuestAdditionsUninstallOld.nsh 98103 2023-01-17 14:15:46Z vboxsync $
|
---|
[43129] | 2 | ;; @file
|
---|
[69354] | 3 | ; VBoxGuestAdditionsUninstallOld.nsh - Guest Additions uninstallation handling for legacy packages.
|
---|
[43129] | 4 | ;
|
---|
| 5 |
|
---|
| 6 | ;
|
---|
[98103] | 7 | ; Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
[43129] | 8 | ;
|
---|
[96407] | 9 | ; This file is part of VirtualBox base platform packages, as
|
---|
| 10 | ; available from https://www.virtualbox.org.
|
---|
[43129] | 11 | ;
|
---|
[96407] | 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 | ;
|
---|
[43129] | 27 |
|
---|
[96693] | 28 | !ifdef UNUSED_CODE
|
---|
[43129] | 29 | !macro Uninstall_RunExtUnInstaller un
|
---|
| 30 | Function ${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 |
|
---|
| 43 | run:
|
---|
| 44 |
|
---|
| 45 | ; Always try to run in silent mode
|
---|
| 46 | Goto run_uninst_silent
|
---|
| 47 |
|
---|
| 48 | run_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 |
|
---|
| 53 | run_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 |
|
---|
| 58 | handle_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 |
|
---|
| 84 | exit:
|
---|
| 85 |
|
---|
| 86 | Pop $2
|
---|
| 87 | Pop $1
|
---|
| 88 | Push $0
|
---|
| 89 |
|
---|
| 90 | FunctionEnd
|
---|
| 91 | !macroend
|
---|
| 92 | !insertmacro Uninstall_RunExtUnInstaller ""
|
---|
| 93 | !insertmacro Uninstall_RunExtUnInstaller "un."
|
---|
[96693] | 94 | !endif ; UNUSED_CODE
|
---|
[43129] | 95 |
|
---|
| 96 | !macro Uninstall_WipeInstallationDirectory un
|
---|
| 97 | Function ${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 ...
|
---|
[44417] | 104 | ${LogVerbose} "Removing old installation directory ($0) ..."
|
---|
[43129] | 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
|
---|
[44417] | 112 | ${LogVerbose} "Wiping ($0) ..."
|
---|
[43129] | 113 | Goto wipe
|
---|
| 114 | ${EndIf}
|
---|
| 115 | Goto wipe_abort
|
---|
| 116 |
|
---|
| 117 | wipe:
|
---|
| 118 |
|
---|
| 119 | RMDir /r /REBOOTOK "$0"
|
---|
| 120 | StrCpy $0 0 ; All went well
|
---|
| 121 | Goto exit
|
---|
| 122 |
|
---|
| 123 | wipe_abort:
|
---|
| 124 |
|
---|
[44417] | 125 | ${LogVerbose} "Won't remove directory ($0)!"
|
---|
[43129] | 126 | StrCpy $0 1 ; Signal some failure
|
---|
| 127 | Goto exit
|
---|
| 128 |
|
---|
| 129 | exit:
|
---|
| 130 |
|
---|
| 131 | Pop $2
|
---|
| 132 | Pop $1
|
---|
| 133 | Push $0
|
---|
| 134 |
|
---|
| 135 | FunctionEnd
|
---|
| 136 | !macroend
|
---|
| 137 | !insertmacro Uninstall_WipeInstallationDirectory ""
|
---|
| 138 |
|
---|
| 139 | ; This function cleans up an old Sun installation
|
---|
| 140 | !macro Uninstall_Sun un
|
---|
| 141 | Function ${un}Uninstall_Sun
|
---|
| 142 |
|
---|
| 143 | Push $0
|
---|
| 144 | Push $1
|
---|
| 145 | Push $2
|
---|
| 146 |
|
---|
| 147 | ; Get current installation path
|
---|
| 148 | ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Sun VirtualBox Guest Additions" "UninstallString"
|
---|
| 149 | StrCmp $0 "" exit
|
---|
| 150 |
|
---|
| 151 | ; Extract path
|
---|
| 152 | Push "$0" ; String
|
---|
| 153 | Push "\" ; SubString
|
---|
| 154 | Push "<" ; SearchDirection
|
---|
| 155 | Push "<" ; StrInclusionDirection
|
---|
| 156 | Push "0" ; IncludeSubString
|
---|
| 157 | Push "0" ; Loops
|
---|
| 158 | Push "0" ; CaseSensitive
|
---|
| 159 | Call ${un}StrStrAdv
|
---|
| 160 | Pop $1 ; $1 only contains the full path
|
---|
| 161 |
|
---|
| 162 | StrCmp $1 "" exit
|
---|
| 163 |
|
---|
| 164 | ; Save current i8042prt info to new uninstall registry path
|
---|
| 165 | ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Sun VirtualBox Guest Additions" ${ORG_MOUSE_PATH}
|
---|
| 166 | WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" ${ORG_MOUSE_PATH} $0
|
---|
| 167 |
|
---|
| 168 | ; Try to wipe current installation directory
|
---|
| 169 | Push $1 ; Push uninstaller path to stack
|
---|
| 170 | Call ${un}Uninstall_WipeInstallationDirectory
|
---|
| 171 | Pop $2 ; Get uninstaller exit code from stack
|
---|
| 172 | StrCmp $2 0 common exit ; Only process common part if exit code is 0, otherwise exit
|
---|
| 173 |
|
---|
| 174 | common:
|
---|
| 175 |
|
---|
| 176 | ; Make sure everything is cleaned up in case the old uninstaller did forget something
|
---|
| 177 | DeleteRegKey HKLM "SOFTWARE\Sun\VirtualBox Guest Additions"
|
---|
| 178 | DeleteRegKey /ifempty HKLM "SOFTWARE\Sun"
|
---|
| 179 | DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Sun VirtualBox Guest Additions"
|
---|
| 180 | Delete /REBOOTOK "$1\netamd.inf"
|
---|
| 181 | Delete /REBOOTOK "$1\pcntpci5.cat"
|
---|
| 182 | Delete /REBOOTOK "$1\PCNTPCI5.sys"
|
---|
| 183 |
|
---|
| 184 | ; Try to remove old installation directory if empty
|
---|
| 185 | RMDir /r /REBOOTOK "$SMPROGRAMS\Sun VirtualBox Guest Additions"
|
---|
| 186 | RMDir /REBOOTOK "$1"
|
---|
| 187 |
|
---|
| 188 | ; Get original mouse driver info and restore it
|
---|
| 189 | ;ReadRegStr $0 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" ${ORG_MOUSE_PATH}
|
---|
| 190 | ;WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\i8042prt" "ImagePath" $0
|
---|
| 191 | ;Delete "$SYSDIR\drivers\VBoxMouseNT.sys"
|
---|
| 192 |
|
---|
| 193 | ; Delete vendor installation directory (only if completely empty)
|
---|
[84945] | 194 | !if $%KBUILD_TARGET_ARCH% == "x86" ; 32-bit
|
---|
[43129] | 195 | RMDir /REBOOTOK "$PROGRAMFILES32\Sun"
|
---|
| 196 | !else ; 64-bit
|
---|
| 197 | RMDir /REBOOTOK "$PROGRAMFILES64\Sun"
|
---|
| 198 | !endif
|
---|
| 199 |
|
---|
| 200 | exit:
|
---|
| 201 |
|
---|
| 202 | Pop $2
|
---|
| 203 | Pop $1
|
---|
| 204 | Pop $0
|
---|
| 205 |
|
---|
| 206 | FunctionEnd
|
---|
| 207 | !macroend
|
---|
| 208 | !insertmacro Uninstall_Sun ""
|
---|
| 209 |
|
---|
| 210 | ; This function cleans up an old xVM Sun installation
|
---|
| 211 | !macro Uninstall_SunXVM un
|
---|
| 212 | Function ${un}Uninstall_SunXVM
|
---|
| 213 |
|
---|
| 214 | Push $0
|
---|
| 215 | Push $1
|
---|
| 216 | Push $2
|
---|
| 217 |
|
---|
| 218 | ; Get current installation path
|
---|
| 219 | ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Sun xVM VirtualBox Guest Additions" "UninstallString"
|
---|
| 220 | StrCmp $0 "" exit
|
---|
| 221 |
|
---|
| 222 | ; Extract path
|
---|
| 223 | Push "$0" ; String
|
---|
| 224 | Push "\" ; SubString
|
---|
| 225 | Push "<" ; SearchDirection
|
---|
| 226 | Push "<" ; StrInclusionDirection
|
---|
| 227 | Push "0" ; IncludeSubString
|
---|
| 228 | Push "0" ; Loops
|
---|
| 229 | Push "0" ; CaseSensitive
|
---|
| 230 | Call ${un}StrStrAdv
|
---|
| 231 | Pop $1 ; $1 only contains the full path
|
---|
| 232 |
|
---|
| 233 | StrCmp $1 "" exit
|
---|
| 234 |
|
---|
| 235 | ; Save current i8042prt info to new uninstall registry path
|
---|
| 236 | ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Sun xVM VirtualBox Guest Additions" ${ORG_MOUSE_PATH}
|
---|
| 237 | WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" ${ORG_MOUSE_PATH} $0
|
---|
| 238 |
|
---|
| 239 | ; Try to wipe current installation directory
|
---|
| 240 | Push $1 ; Push uninstaller path to stack
|
---|
| 241 | Call ${un}Uninstall_WipeInstallationDirectory
|
---|
| 242 | Pop $2 ; Get uninstaller exit code from stack
|
---|
| 243 | StrCmp $2 0 common exit ; Only process common part if exit code is 0, otherwise exit
|
---|
| 244 |
|
---|
| 245 | common:
|
---|
| 246 |
|
---|
| 247 | ; Make sure everything is cleaned up in case the old uninstaller did forget something
|
---|
| 248 | DeleteRegKey HKLM "SOFTWARE\Sun\xVM VirtualBox Guest Additions"
|
---|
| 249 | DeleteRegKey /ifempty HKLM "SOFTWARE\Sun"
|
---|
| 250 | DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Sun xVM VirtualBox Guest Additions"
|
---|
| 251 | Delete /REBOOTOK "$1\netamd.inf"
|
---|
| 252 | Delete /REBOOTOK "$1\pcntpci5.cat"
|
---|
| 253 | Delete /REBOOTOK "$1\PCNTPCI5.sys"
|
---|
| 254 |
|
---|
| 255 | ; Try to remove old installation directory if empty
|
---|
| 256 | RMDir /r /REBOOTOK "$SMPROGRAMS\Sun xVM VirtualBox Guest Additions"
|
---|
| 257 | RMDir /REBOOTOK "$1"
|
---|
| 258 |
|
---|
| 259 | ; Delete vendor installation directory (only if completely empty)
|
---|
[84945] | 260 | !if $%KBUILD_TARGET_ARCH% == "x86" ; 32-bit
|
---|
[43129] | 261 | RMDir /REBOOTOK "$PROGRAMFILES32\Sun"
|
---|
| 262 | !else ; 64-bit
|
---|
| 263 | RMDir /REBOOTOK "$PROGRAMFILES64\Sun"
|
---|
| 264 | !endif
|
---|
| 265 |
|
---|
| 266 | ; Get original mouse driver info and restore it
|
---|
| 267 | ;ReadRegStr $0 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" ${ORG_MOUSE_PATH}
|
---|
| 268 | ;WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\i8042prt" "ImagePath" $0
|
---|
| 269 | ;Delete "$SYSDIR\drivers\VBoxMouseNT.sys"
|
---|
| 270 |
|
---|
| 271 | exit:
|
---|
| 272 |
|
---|
| 273 | Pop $2
|
---|
| 274 | Pop $1
|
---|
| 275 | Pop $0
|
---|
| 276 |
|
---|
| 277 | FunctionEnd
|
---|
| 278 | !macroend
|
---|
| 279 | !insertmacro Uninstall_SunXVM ""
|
---|
| 280 |
|
---|
| 281 | ; This function cleans up an old innotek installation
|
---|
| 282 | !macro Uninstall_Innotek un
|
---|
| 283 | Function ${un}Uninstall_Innotek
|
---|
| 284 |
|
---|
| 285 | Push $0
|
---|
| 286 | Push $1
|
---|
| 287 | Push $2
|
---|
| 288 |
|
---|
| 289 | ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\innotek VirtualBox Guest Additions" "UninstallString"
|
---|
| 290 | StrCmp $0 "" exit
|
---|
| 291 |
|
---|
| 292 | ; Extract path
|
---|
| 293 | Push "$0" ; String
|
---|
| 294 | Push "\" ; SubString
|
---|
| 295 | Push "<" ; SearchDirection
|
---|
| 296 | Push "<" ; StrInclusionDirection
|
---|
| 297 | Push "0" ; IncludeSubString
|
---|
| 298 | Push "0" ; Loops
|
---|
| 299 | Push "0" ; CaseSensitive
|
---|
| 300 | Call ${un}StrStrAdv
|
---|
| 301 | Pop $1 ; $1 only contains the full path
|
---|
| 302 |
|
---|
| 303 | StrCmp $1 "" exit
|
---|
| 304 |
|
---|
| 305 | ; Save current i8042prt info to new uninstall registry path
|
---|
| 306 | ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\innotek VirtualBox Guest Additions" ${ORG_MOUSE_PATH}
|
---|
| 307 | WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" ${ORG_MOUSE_PATH} $0
|
---|
| 308 |
|
---|
| 309 | ; Try to wipe current installation directory
|
---|
| 310 | Push $1 ; Push uninstaller path to stack
|
---|
| 311 | Call ${un}Uninstall_WipeInstallationDirectory
|
---|
| 312 | Pop $2 ; Get uninstaller exit code from stack
|
---|
| 313 | StrCmp $2 0 common exit ; Only process common part if exit code is 0, otherwise exit
|
---|
| 314 |
|
---|
| 315 | common:
|
---|
| 316 |
|
---|
| 317 | ; Remove left over files which were not entirely cached by the formerly running
|
---|
| 318 | ; uninstaller
|
---|
| 319 | DeleteRegKey HKLM "SOFTWARE\innotek\VirtualBox Guest Additions"
|
---|
| 320 | DeleteRegKey HKLM "SOFTWARE\innotek"
|
---|
| 321 | DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\innotek VirtualBox Guest Additions"
|
---|
| 322 | Delete /REBOOTOK "$1\VBoxGuestDrvInst.exe"
|
---|
| 323 | Delete /REBOOTOK "$1\VBoxMouseInst.exe"
|
---|
| 324 | Delete /REBOOTOK "$1\VBoxSFDrvInst.exe"
|
---|
| 325 | Delete /REBOOTOK "$1\RegCleanup.exe"
|
---|
| 326 | Delete /REBOOTOK "$1\VBoxService.exe"
|
---|
| 327 | Delete /REBOOTOK "$1\VBoxMouseInst.exe"
|
---|
| 328 | Delete /REBOOTOK "$1\innotek VirtualBox Guest Additions.url"
|
---|
| 329 | Delete /REBOOTOK "$1\uninst.exe"
|
---|
| 330 | Delete /REBOOTOK "$1\iexplore.ico"
|
---|
| 331 | Delete /REBOOTOK "$1\install.log"
|
---|
| 332 | Delete /REBOOTOK "$1\VBCoInst.dll"
|
---|
| 333 | Delete /REBOOTOK "$1\VBoxControl.exe"
|
---|
| 334 | Delete /REBOOTOK "$1\VBoxDisp.dll"
|
---|
| 335 | Delete /REBOOTOK "$1\VBoxGINA.dll"
|
---|
| 336 | Delete /REBOOTOK "$1\VBoxGuest.cat"
|
---|
| 337 | Delete /REBOOTOK "$1\VBoxGuest.inf"
|
---|
| 338 | Delete /REBOOTOK "$1\VBoxGuest.sys"
|
---|
| 339 | Delete /REBOOTOK "$1\VBoxMouse.inf"
|
---|
| 340 | Delete /REBOOTOK "$1\VBoxMouse.sys"
|
---|
| 341 | Delete /REBOOTOK "$1\VBoxVideo.cat"
|
---|
| 342 | Delete /REBOOTOK "$1\VBoxVideo.inf"
|
---|
| 343 | Delete /REBOOTOK "$1\VBoxVideo.sys"
|
---|
| 344 |
|
---|
| 345 | ; Try to remove old installation directory if empty
|
---|
| 346 | RMDir /r /REBOOTOK "$SMPROGRAMS\innotek VirtualBox Guest Additions"
|
---|
| 347 | RMDir /REBOOTOK "$1"
|
---|
| 348 |
|
---|
| 349 | ; Delete vendor installation directory (only if completely empty)
|
---|
[84945] | 350 | !if $%KBUILD_TARGET_ARCH% == "x86" ; 32-bit
|
---|
[43129] | 351 | RMDir /REBOOTOK "$PROGRAMFILES32\innotek"
|
---|
| 352 | !else ; 64-bit
|
---|
| 353 | RMDir /REBOOTOK "$PROGRAMFILES64\innotek"
|
---|
| 354 | !endif
|
---|
| 355 |
|
---|
| 356 | ; Get original mouse driver info and restore it
|
---|
| 357 | ;ReadRegStr $0 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" ${ORG_MOUSE_PATH}
|
---|
| 358 | ;WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\i8042prt" "ImagePath" $0
|
---|
| 359 | ;Delete "$SYSDIR\drivers\VBoxMouseNT.sys"
|
---|
| 360 |
|
---|
| 361 | exit:
|
---|
| 362 |
|
---|
| 363 | Pop $2
|
---|
| 364 | Pop $1
|
---|
| 365 | Pop $0
|
---|
| 366 |
|
---|
| 367 | FunctionEnd
|
---|
| 368 | !macroend
|
---|
| 369 | !insertmacro Uninstall_Innotek ""
|
---|