sbsv2/raptor/util/install-windows/raptorinstallerscript.nsi
changeset 0 044383f39525
child 3 e1eecf4d390d
child 590 360bd6b35136
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 # All rights reserved.
       
     3 # This component and the accompanying materials are made available
       
     4 # under the terms of the License "Eclipse Public License v1.0"
       
     5 # which accompanies this distribution, and is available
       
     6 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 #
       
     8 # Initial Contributors:
       
     9 # Nokia Corporation - initial contribution.
       
    10 #
       
    11 # Contributors:
       
    12 #
       
    13 # Description: 
       
    14 # Raptor installer/uninstaller script
       
    15 
       
    16 # Standard NSIS Library includes 
       
    17 !include "MUI2.nsh"
       
    18 !include "LogicLib.nsh"
       
    19 !include "WinMessages.nsh"
       
    20 
       
    21 # Extra plugin includes
       
    22 !include "nsDialogs.nsh"
       
    23 !include "Registry.nsh"
       
    24 !include "NSISpcre.nsh"
       
    25 !include "Time.nsh"
       
    26 
       
    27 # Define functions from NSISpcre.nsh 
       
    28 !insertmacro REMatches
       
    29 !insertmacro un.REMatches
       
    30 !insertmacro REQuoteMeta
       
    31 
       
    32 # Variables
       
    33 Var DIALOG
       
    34 Var RESULT # Generic variable to obtain results, and immediately thrown away after
       
    35 Var RESULT2 # Generic variable to obtain results, and immediately thrown away after
       
    36 Var SBS_HOME
       
    37 Var USERONLYINSTALL_HWND # HWND of radio button control for user-only installation
       
    38 Var ALLUSERSINSTALL_HWND # HWND of radio button control for system installation
       
    39 Var NOENVCHANGES_HWND    # HWND of radio button control for file-only installation
       
    40 Var USERONLYINSTALL_STATE # State of user-only radio button
       
    41 Var ALLUSERSINSTALL_STATE # State of system radio button
       
    42 Var NOENVCHANGES_STATE # State of file-only installation radio button
       
    43 Var INSTALL_TYPE # Type of installer ("USR" or "SYS")
       
    44 
       
    45 # Custom includes (depend on above variables so much be here)
       
    46 !include "raptorinstallerutils.nsh" # Functions and macros for handling environment variables
       
    47 !include "raptorversion.nsh" # Define the RAPTOR_VERSION variable
       
    48 
       
    49 # Defines
       
    50 # !define /date DATE_STAMP "%Y-%m-%d-%H-%M-%S"
       
    51 !define INSTALLER_NAME "Raptor v${RAPTOR_VERSION}"
       
    52 !define RAPTOR "sbs"
       
    53 !define INSTALLER_FILENAME "${RAPTOR}-${RAPTOR_VERSION}.exe"
       
    54 !define UNINSTALLER_FILENAME "${RAPTOR}-${RAPTOR_VERSION}-uninstaller.exe"
       
    55 
       
    56 ########################## Attributes ###########################
       
    57 # Name of installer executable to create!
       
    58 OutFile ${INSTALLER_FILENAME}
       
    59 # Name for the installer caption
       
    60 Name "Raptor v${RAPTOR_VERSION}"
       
    61 
       
    62 ####################### Generic Behaviour #######################
       
    63 # Vista support; use admin in case user decides to install Raptor for all users
       
    64 RequestExecutionLevel admin
       
    65 # Set XPStyle on
       
    66 XPStyle on
       
    67 
       
    68 ###################### Installer Behaviour ######################
       
    69 # Warn on Cancel
       
    70 !define MUI_ABORTWARNING
       
    71 # Abort warning text
       
    72 !define MUI_ABORTWARNING_TEXT "Are you sure you want to quit the ${INSTALLER_NAME} installer?"
       
    73 # Cancel is default button on cancel dialogue boxes.
       
    74 !define MUI_ABORTWARNING_CANCEL_DEFAULT
       
    75 # Don't just to final page
       
    76 !define MUI_FINISHPAGE_NOAUTOCLOSE
       
    77 # Show installer details
       
    78 ShowInstDetails show
       
    79 
       
    80 ##################### Pages in the installer #####################
       
    81 !insertmacro MUI_PAGE_WELCOME
       
    82 # Temporarily useing RELEASE-NOTES.txt as there is not license.txt
       
    83 !insertmacro MUI_PAGE_LICENSE ${RAPTOR_LOCATION}\RELEASE-NOTES.txt
       
    84 !define MUI_PAGE_HEADER_TEXT "Installation type"
       
    85 Page custom UserOrSysInstall UserOrSysInstallLeave
       
    86 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE DirLeave # Directory page exit function - disallow spaces in $INSTDIR
       
    87 !insertmacro MUI_PAGE_DIRECTORY
       
    88 !insertmacro MUI_PAGE_INSTFILES
       
    89 !insertmacro MUI_PAGE_FINISH
       
    90 
       
    91 ######################## .onInit function ########################
       
    92 Function .onInit
       
    93     StrCpy $INSTDIR "C:\Apps\Raptor"
       
    94 FunctionEnd
       
    95 
       
    96 #################### Sections in the installer ####################
       
    97 # "Sections" - i.e. components to install. This installer
       
    98 # only has Raptor, so there is no point giving options 
       
    99 # to the user.
       
   100 Section "Install Raptor" INSTALLRAPTOR
       
   101 	
       
   102     StrCpy $SBS_HOME "SBS_HOME"
       
   103 	
       
   104     # Install Raptor
       
   105     SetOutPath "$INSTDIR\bin"
       
   106     File /r ${RAPTOR_LOCATION}\bin\*.* 
       
   107     SetOutPath "$INSTDIR\examples"
       
   108     File /r ${RAPTOR_LOCATION}\examples\*.*
       
   109     SetOutPath "$INSTDIR\lib"
       
   110     File /r ${RAPTOR_LOCATION}\lib\*.*
       
   111     SetOutPath "$INSTDIR\python"
       
   112     File /r ${RAPTOR_LOCATION}\python\*.*
       
   113     SetOutPath "$INSTDIR\schema"
       
   114     File /r ${RAPTOR_LOCATION}\schema\*.*
       
   115     SetOutPath "$INSTDIR\win32"
       
   116     File /r ${RAPTOR_LOCATION}\win32\*.*
       
   117     
       
   118     SetOutPath "$INSTDIR"
       
   119     File ${RAPTOR_LOCATION}\RELEASE-NOTES.txt
       
   120     
       
   121     
       
   122     ${Unless} $INSTALL_TYPE == "NO_ENV"
       
   123         # Back up system and user environments before changing them.
       
   124         !insertmacro DefineDateStamp
       
   125         !define SYS_REG_BACKUP_FILE "$INSTDIR\SysEnvBackUpPreInstall-${DATE_STAMP}.reg"
       
   126         !define USR_REG_BACKUP_FILE "$INSTDIR\UsrEnvBackUpPreInstall-${DATE_STAMP}.reg"
       
   127         
       
   128         # Save System Environment just in case.
       
   129         ${registry::SaveKey} "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "${SYS_REG_BACKUP_FILE}" "" "$RESULT"
       
   130         
       
   131         ${If} $RESULT == 0
       
   132             DetailPrint "Successfully backed up system environment in ${SYS_REG_BACKUP_FILE}."
       
   133         ${Else}
       
   134             DetailPrint "Failed to back up system environment due to an unknown error."
       
   135         ${EndIf}
       
   136         
       
   137         # Save user Environment just in case.
       
   138         ${registry::SaveKey} "HKCU\Environment" "${USR_REG_BACKUP_FILE}" "" "$RESULT"
       
   139         
       
   140         ${If} $RESULT == 0
       
   141             DetailPrint "Successfully backed up user environment in ${USR_REG_BACKUP_FILE}."
       
   142         ${Else}
       
   143             DetailPrint "Failed to back up user environment due to an unknown error."
       
   144         ${EndIf}
       
   145     	
       
   146     	# Reset error flag
       
   147     	ClearErrors
       
   148     	
       
   149     	# Write SBS_HOME variable; if it exists, the user will be asked if they want it to be overwritten.
       
   150     	# Read the env var from the appropriate place
       
   151     	!insertmacro ReadEnvVar $SBS_HOME $RESULT
       
   152     	
       
   153     	${Unless} ${Errors} # No errors, so $SBS_HOME exists
       
   154     		DetailPrint "Env Var $SBS_HOME exists with value $RESULT"
       
   155     		# Ask user if they want it replaced. If yes, write it, if no don't write it.
       
   156     		MessageBox MB_YESNO|MB_ICONQUESTION "The ${INSTALLER_NAME} installer has detected that you already have the SBS_HOME environment variable set with value $RESULT. Would you like the installer to overwrite it with the value $INSTDIR? Click yes to over write with value $INSTDIR, and no to leave it as $RESULT." IDYES write_env_var_yes IDNO write_env_var_no
       
   157     	${Else} # No env var named $SBS_HOME
       
   158     		DetailPrint "Env Var $SBS_HOME does not exist!"
       
   159     	${EndUnless}
       
   160     	
       
   161 write_env_var_yes:
       
   162     	# Write SBS_HOME to registry
       
   163     	Push "SBS_HOME" # Third on stack
       
   164     	Push "$INSTDIR" # Second on stack
       
   165     	Push "" # First on stack
       
   166     	
       
   167     	# Needs env var name, env var value, then "" on the stack
       
   168     	call WriteEnvVar
       
   169     	
       
   170     	# Prepend PATH with %SBS_HOME%\bin
       
   171     	Push "%SBS_HOME%\bin" # First on stack
       
   172     	call PrependToPath
       
   173     	goto end
       
   174         
       
   175 write_env_var_no:
       
   176     	DetailPrint "Not writing the environment variable $SBS_HOME."
       
   177         
       
   178 end:
       
   179     ${EndUnless} 
       
   180 	
       
   181 	# Generate batch file to set environment variables for Raptor
       
   182 	StrCpy $RESULT "@REM Environment variables for ${INSTALLER_NAME}$\r$\nset SBS_HOME=$INSTDIR$\r$\nset PATH=%SBS_HOME%\bin;%PATH%$\r$\n"
       
   183 	!insertmacro WriteFile "RaptorEnv.bat" "$RESULT"
       
   184 SectionEnd
       
   185 
       
   186 # Finishing up installation.
       
   187 Section
       
   188     ${Unless} $INSTALL_TYPE == "NO_ENV"
       
   189     	# Refresh environment to get changes for SBS_HOME and PATH
       
   190         !insertmacro RefreshEnv
       
   191     ${EndUnless}
       
   192 	
       
   193 	# Write the uninstaller
       
   194 	# WriteUninstaller "$INSTDIR\${UNINSTALLER_FILENAME}"
       
   195 	WriteUninstaller "$INSTDIR\${UNINSTALLER_FILENAME}"
       
   196 	# Unload registry plug in
       
   197 	${registry::Unload}
       
   198 SectionEnd
       
   199 
       
   200 # Custom install page to select install type
       
   201 Function UserOrSysInstall
       
   202     !insertmacro MUI_HEADER_TEXT "Choose Installation Type" "Choose the type of installation \
       
   203     you would like for your computer."
       
   204     
       
   205 	nsDialogs::Create 1018
       
   206 	Pop $DIALOG
       
   207 	
       
   208 	# Exit is unable to create dialog
       
   209 	${If} $DIALOG == error
       
   210 		Abort
       
   211 	${EndIf}
       
   212 	
       
   213 	# Create second radio button for system install
       
   214 	#${NSD_CreateRadioButton} 0 10u 100% 33% "Install Raptor for all users on this computer. \
       
   215     #(Recommended).$\nThis option modifies system wide environment variables."
       
   216 	#Pop $ALLUSERSINSTALL_HWND
       
   217     
       
   218     # Create first radio button for user install
       
   219     #${NSD_CreateRadioButton} 0 45u 100% 67% "Install Raptor just for me on this computer.\
       
   220     #$\nThis option modifies only user environment variables."
       
   221     #Pop $USERONLYINSTALL_HWND
       
   222 	
       
   223 	# Create first radio button for system install
       
   224 	${NSD_CreateRadioButton} 0 0% 100% 30% "Install Raptor for all users on this computer. \
       
   225     (Recommended).$\nThis option modifies system wide environment variables."
       
   226 	Pop $ALLUSERSINSTALL_HWND
       
   227     
       
   228     # Create second radio button for user install
       
   229     ${NSD_CreateRadioButton} 0 25% 100% 30% "Install Raptor just for me on this computer.\
       
   230     $\nThis option modifies only user environment variables."
       
   231     Pop $USERONLYINSTALL_HWND
       
   232     
       
   233     # Create third radio button for file-only install
       
   234     ${NSD_CreateRadioButton} 0 50% 100% 40% "Install, but do not modify the environment.\
       
   235     $\nThis option only unpacks Raptor's files. A batch file in the installation \ 
       
   236     folder (RaptorEnv.bat) can be used to set Raptor's environment variables in a command prompt."
       
   237     Pop $NOENVCHANGES_HWND
       
   238 	
       
   239 	# Update page control with previous state, if set.
       
   240 	# Initially these will be blank, so set system install to be on by default.
       
   241 	${If} $USERONLYINSTALL_STATE == ""
       
   242 	${AndIf} $ALLUSERSINSTALL_STATE == ""
       
   243     ${AndIf} $NOENVCHANGES_STATE == ""
       
   244 		${NSD_SetState} $ALLUSERSINSTALL_HWND ${BST_CHECKED}
       
   245 	${Else} # Previously set, user has returned to this page using "Back" button
       
   246 		${If} $USERONLYINSTALL_STATE == ${BST_CHECKED}
       
   247 			${NSD_SetState} $USERONLYINSTALL_HWND ${BST_CHECKED}
       
   248 		${ElseIf} $NOENVCHANGES_STATE == ${BST_CHECKED}
       
   249             ${NSD_SetState} $NOENVCHANGES_HWND ${BST_CHECKED}
       
   250         ${Else}
       
   251 			${NSD_SetState} $ALLUSERSINSTALL_HWND ${BST_CHECKED}
       
   252 		${EndIf}
       
   253 	${EndIf}
       
   254 	
       
   255 	nsDialogs::Show
       
   256 FunctionEnd
       
   257 
       
   258 # Store the states of the radio buttons once the user has left the page.
       
   259 Function UserOrSysInstallLeave
       
   260 	${NSD_GetState} $USERONLYINSTALL_HWND $USERONLYINSTALL_STATE
       
   261 	${NSD_GetState} $ALLUSERSINSTALL_HWND $ALLUSERSINSTALL_STATE
       
   262     ${NSD_GetState} $NOENVCHANGES_HWND $NOENVCHANGES_STATE
       
   263     
       
   264     # Set the ${INSTALL_TYPE} variable
       
   265     ${If} $USERONLYINSTALL_STATE == ${BST_CHECKED}
       
   266         StrCpy $INSTALL_TYPE "USR"
       
   267     ${EndIf}
       
   268     
       
   269     ${If} $ALLUSERSINSTALL_STATE == ${BST_CHECKED}
       
   270         StrCpy $INSTALL_TYPE "SYS"
       
   271     ${EndIf}
       
   272     
       
   273     ${If} $NOENVCHANGES_STATE == ${BST_CHECKED}
       
   274         StrCpy $INSTALL_TYPE "NO_ENV"
       
   275     ${EndIf}
       
   276     
       
   277     ${Unless} $INSTALL_TYPE == "USR"
       
   278     ${AndUnless} $INSTALL_TYPE == "SYS"
       
   279     ${AndUnless} $INSTALL_TYPE == "NO_ENV"
       
   280         Abort "Failed to determine installation type.\n\
       
   281         $$INSTALL_TYPE = $\"$INSTALL_TYPE$\"."
       
   282     ${EndUnless} 
       
   283 FunctionEnd
       
   284 
       
   285 Function DirLeave
       
   286 	StrCpy $0 " "
       
   287 	${REQuoteMeta} $9 $0 # $9 now contains the meta-quoted version of $0
       
   288 	${If} $INSTDIR =~ $9
       
   289 		MessageBox MB_OK|MB_ICONSTOP "Please choose a directory without a space in it."
       
   290 		Abort
       
   291 	${EndIf}
       
   292 FunctionEnd
       
   293 
       
   294 ########################### Uninstaller #########################
       
   295 ######################## .onInit function ########################
       
   296 Function un.onInit
       
   297 	!undef DATE_STAMP
       
   298 	!insertmacro DefineDateStamp
       
   299 FunctionEnd
       
   300 ########################### Behaviour ###########################
       
   301 # Warn on Cancel
       
   302 !define MUI_UNABORTWARNING
       
   303 # Abort warning text
       
   304 !undef MUI_UNABORTWARNING_TEXT
       
   305 !define MUI_UNABORTWARNING_TEXT "Are you sure you want to quit the ${INSTALLER_NAME} uninstaller?"
       
   306 # Cancel is default button on cancel dialogue boxes.
       
   307 !define MUI_UNABORTWARNING_CANCEL_DEFAULT
       
   308 # Don't just to final page
       
   309 !define MUI_UNFINISHPAGE_NOAUTOCLOSE
       
   310 # Show uninstaller details
       
   311 ShowUninstDetails show
       
   312 
       
   313 #################### Pages in the uninstaller ####################
       
   314 !insertmacro MUI_UNPAGE_WELCOME
       
   315 !insertmacro MUI_UNPAGE_CONFIRM
       
   316 !insertmacro MUI_UNPAGE_INSTFILES
       
   317 !insertmacro MUI_UNPAGE_FINISH
       
   318 
       
   319 ################## Sections in the uninstaller ##################
       
   320 # There is only one section in the uninstaller.
       
   321 Section "Uninstall"
       
   322     # Delete Raptor
       
   323     RmDir /r $INSTDIR\bin
       
   324     RmDir /r $INSTDIR\examples
       
   325     RmDir /r $INSTDIR\lib
       
   326     RmDir /r $INSTDIR\python
       
   327     RmDir /r $INSTDIR\schema
       
   328     RmDir /r $INSTDIR\win32
       
   329     Delete $INSTDIR\RELEASE-NOTES.txt
       
   330     Delete $INSTDIR\RaptorEnv.bat
       
   331     Delete $INSTDIR\${UNINSTALLER_FILENAME}
       
   332     
       
   333     !undef SYS_REG_BACKUP_FILE
       
   334     !undef USR_REG_BACKUP_FILE
       
   335     !define SYS_REG_BACKUP_FILE "$INSTDIR\SysEnvBackUpPreUninstall-${DATE_STAMP}.reg"
       
   336     !define USR_REG_BACKUP_FILE "$INSTDIR\UsrEnvBackUpPreUninstall-${DATE_STAMP}.reg"
       
   337     
       
   338     # Save System Environment just in case.
       
   339     ${registry::SaveKey} "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "${SYS_REG_BACKUP_FILE}" "" "$RESULT"
       
   340     
       
   341     ${If} $RESULT == 0
       
   342         DetailPrint "Successfully backed up system environment in ${SYS_REG_BACKUP_FILE}."
       
   343     ${Else}
       
   344         DetailPrint "Failed to back up system environment due to an unknown error."
       
   345     ${EndIf}
       
   346     
       
   347     # Save user Environment just in case.
       
   348     ${registry::SaveKey} "HKCU\Environment" "${USR_REG_BACKUP_FILE}" "" "$RESULT"
       
   349     
       
   350     ${If} $RESULT == 0
       
   351         DetailPrint "Successfully backed up user environment in ${USR_REG_BACKUP_FILE}."
       
   352     ${Else}
       
   353         DetailPrint "Failed to back up user environment due to an unknown error."
       
   354     ${EndIf}
       
   355 	
       
   356 	# Reset error flag
       
   357 	ClearErrors
       
   358 	
       
   359 	# Read user SBS_HOME
       
   360 	!insertmacro ReadUsrEnvVar "SBS_HOME" $RESULT
       
   361 	
       
   362 	${Unless} ${Errors} # No errors, so user %SBS_HOME% exists
       
   363 		DetailPrint "Removing user environment variable SBS_HOME ($RESULT)"
       
   364 		
       
   365 		# Reset error flag
       
   366 		ClearErrors
       
   367 		!insertmacro RmUsrEnvVar "SBS_HOME"
       
   368 		
       
   369 		${If} ${Errors}
       
   370 			DetailPrint "ERROR: The ${INSTALLER_NAME} uninstaller could not remove the user environment variable SBS_HOME."
       
   371 			DetailPrint "Please remove it manually."
       
   372 		${EndIf}
       
   373 		
       
   374 	${Else} # No env var named $SBS_HOME
       
   375 		DetailPrint "Note: Unable to find user environment variable SBS_HOME."
       
   376 		DetailPrint "If required, this variable may need to be removed manually."
       
   377 	${EndUnless}
       
   378 	
       
   379 	# Reset error flag
       
   380 	ClearErrors
       
   381 	
       
   382 	# Read system SBS_HOME
       
   383 	!insertmacro ReadSysEnvVar "SBS_HOME" $RESULT
       
   384 	
       
   385 	${Unless} ${Errors} # No errors, so system $SBS_HOME exists
       
   386 		DetailPrint "Removing system environment variable SBS_HOME ($RESULT)"
       
   387 		
       
   388 		# Reset error flag
       
   389 		ClearErrors
       
   390 		!insertmacro RmSysEnvVar "SBS_HOME"
       
   391 		
       
   392 		${If} ${Errors}
       
   393 			DetailPrint "ERROR: The ${INSTALLER_NAME} uninstaller could not remove the \
       
   394             System environment variable SBS_HOME."
       
   395 			DetailPrint "Please remove it manually."
       
   396 		${EndIf}
       
   397 		
       
   398 	${Else} # No env var named $SBS_HOME
       
   399 		DetailPrint "Note: Unable to find system environment variable SBS_HOME."
       
   400 		DetailPrint "If required, this variable may need to be removed manually."
       
   401 	${EndUnless}
       
   402 	
       
   403 	################################# Clean up the path env vars #################################
       
   404 	# Reset error flag
       
   405 	ClearErrors
       
   406 	
       
   407 	# Read user path
       
   408 	!insertmacro ReadUsrPath $RESULT
       
   409     DetailPrint "Read user Path: $RESULT"
       
   410 	
       
   411 	${Unless} ${Errors} # No errors, so user $SBS_HOME exists
       
   412 		${If} $RESULT == "" # If it came back empty.
       
   413 			DetailPrint "No user Path available - nothing to do."
       
   414 		${Else}
       
   415             ${If} $RESULT un.=~ "%SBS_HOME%\\bin;" # Only need to act if %SBS_HOME%\bin; is in the Path
       
   416     			DetailPrint "Removing %SBS_HOME%\bin; from user path"
       
   417     			
       
   418     			# Reset error flag and clean user Path
       
   419     			ClearErrors
       
   420     			!insertmacro RemoveFromPathString $RESULT "%SBS_HOME%\bin;"
       
   421     			
       
   422     			DetailPrint "DEBUG: User path $$RESULT = "
       
   423     	        DetailPrint "DEBUG: User path  $RESULT"
       
   424     			
       
   425     			${If} $RESULT == ""
       
   426     				!insertmacro RmUsrEnvVar "Path"
       
   427     			${Else}
       
   428     				# Write cleaned Path to registry
       
   429     	            !insertmacro WriteUsrEnvVarExp "Path" $RESULT
       
   430     			${EndIf}
       
   431     			
       
   432     			${If} ${Errors}
       
   433     				DetailPrint "ERROR: The ${INSTALLER_NAME} uninstaller could not clean the user Path. Please clean it manually."
       
   434     			${EndIf}
       
   435             ${Else}
       
   436                 DetailPrint "Nothing to remove from user path."
       
   437             ${EndIf}
       
   438 		${EndIf}
       
   439 		
       
   440 	${Else} # No user path
       
   441 		DetailPrint "Note: Unable to find user Path environment variable."
       
   442 		DetailPrint "Please check that the variable exists and remove %SBS_HOME\bin manually if required."
       
   443 	${EndUnless}
       
   444     
       
   445     # Read system path
       
   446     !insertmacro ReadSysPath $RESULT
       
   447     DetailPrint "Read system Path: $RESULT"
       
   448     
       
   449     ${Unless} ${Errors} # No errors, so system path read OK.
       
   450         ${If} $RESULT un.=~ "%SBS_HOME%\\bin;" # Only need to act if %SBS_HOME%\bin; is in the Path 
       
   451         
       
   452             DetailPrint "Removing %SBS_HOME%\bin; from system path"
       
   453             
       
   454             # Reset error flag
       
   455             ClearErrors
       
   456             !insertmacro RemoveFromPathString $RESULT "%SBS_HOME%\bin;"
       
   457             DetailPrint "DEBUG: System Path $$RESULT = "
       
   458             DetailPrint "DEBUG: System Path $RESULT"
       
   459             ClearErrors
       
   460             # Write cleaned PATH to registry
       
   461             !insertmacro WriteSysEnvVarExp "Path" $RESULT
       
   462             
       
   463             ${If} ${Errors}
       
   464                 DetailPrint "ERROR: The ${INSTALLER_NAME} uninstaller could not clean the PATH."
       
   465                 DetailPrint "Please clean it manually."
       
   466             ${EndIf}
       
   467         ${Else}
       
   468             DetailPrint "Nothing to remove from system path."
       
   469         ${EndIf}
       
   470     ${Else} # Some error reading system path
       
   471         DetailPrint "Note: Unable to read the system Path environment variable."
       
   472         DetailPrint "Please check that the variable and remove %SBS_HOME\bin manually if required."
       
   473     ${EndUnless}
       
   474 	
       
   475 	##########################################################################
       
   476 	# Refresh environment to get changes for SBS_HOME and PATH
       
   477     !insertmacro RefreshEnv
       
   478 	
       
   479 	# Unload registry plug in
       
   480 	${registry::Unload}
       
   481 SectionEnd
       
   482 
       
   483 # Languages
       
   484 !insertmacro MUI_LANGUAGE "English"
       
   485 
       
   486 ################################################ End ################################################