nsis-20b4-support-20031209
[openafs.git] / src / WINNT / install / NSIS / OpenAFS.nsi
index 2bc731f..1e2f721 100644 (file)
@@ -7,8 +7,24 @@
 ;MultiLanguage Example Script
 ;Written by Joost Verburg
 
-!define MUI_PRODUCT "OpenAFS" ;Define your own software name here
 !include nsi-includes.nsi
+!ifndef v2.0b4
+!define MUI_PRODUCT "OpenAFS" ;Define your own software name here
+!define MUI_VERSION ${AFS_VERSION}
+!else
+Name "OpenAFS ${AFS_VERSION}"
+VIProductVersion "${AFS_VERSION}.00"
+VIAddVersionKey "ProductName" "OpenAFS"
+VIAddVersionKey "CompanyName" "OpenAFS.org"
+VIAddVersionKey "ProductVersion" ${AFS_VERSION}
+VIAddVersionKey "FileVersion" ${AFS_VERSION}
+VIAddVersionKey "FileDescription" "OpenAFS for Windows Installer"
+VIAddVersionKey "LegalCopyright" "(C)2003"
+!ifdef DEBUG
+VIAddVersionKey "PrivateBuild" "Debug"
+!endif
+!endif
+
 ; Define DEBUG if building a DEBUG installer
 ;!define DEBUG 1
 
   SilentInstall normal
   SetCompressor bzip2
   !define MUI_ICON "..\..\client_config\afs_config.ico"
-  !define MUI_UNICON "c:\Program Files\NSIS\Contrib\Icons\normal-uninstall.ico"
+  !ifndef v2.0b4
+  !define MUI_UNICON "${NSISDIR}\Contrib\Icons\normal-uninstall.ico"
+  !else
+  !define MUI_UNICON "..\..\client_config\afs_config.ico"
+  !endif
   !define AFS_COMPANY_NAME "OpenAFS"
   !define AFS_PRODUCT_NAME "OpenAFS"
   !define AFS_REGKEY_ROOT "Software\TransarcCorporation"
   !define MUI_UNCONFIRMPAGE
 
   
+!IFNDEF v2.0b4
   !insertmacro MUI_PAGECOMMAND_WELCOME
-  ;!insertmacro MUI_PAGECOMMAND_LICENSE
+ ;!insertmacro MUI_PAGECOMMAND_LICENSE
   !insertmacro MUI_PAGECOMMAND_COMPONENTS
   !insertmacro MUI_PAGECOMMAND_DIRECTORY
   Page custom AFSPageGetCellServDB
   Page custom AFSPageGetCellName
-  ;Page custom AFSPageGetConfigURL
   !insertmacro MUI_PAGECOMMAND_INSTFILES
   !insertmacro MUI_PAGECOMMAND_FINISH
+!ELSE
+  !insertmacro MUI_PAGE_WELCOME
+  !insertmacro MUI_PAGE_COMPONENTS
+  !insertmacro MUI_PAGE_DIRECTORY
+  Page custom AFSPageGetCellServDB
+  Page custom AFSPageGetCellName
+  !insertmacro MUI_PAGE_INSTFILES
+  !insertmacro MUI_PAGE_FINISH
+!ENDIF
   
   ;LicenseData "Licenses.rtf"
 ;--------------------------------
   !insertmacro MUI_LANGUAGE "SimpChinese"
   !insertmacro MUI_LANGUAGE "TradChinese"    
   !insertmacro MUI_LANGUAGE "Japanese"
-  ;!insertmacro MUI_LANGUAGE "Korean"
+  !ifdef v2.0b4
+  !insertmacro MUI_LANGUAGE "Korean"
+  !endif
   ;!insertmacro MUI_LANGUAGE "Italian"
   ;!insertmacro MUI_LANGUAGE "Dutch"
   ;!insertmacro MUI_LANGUAGE "Danish"
   LangString DESC_SecCopyUI ${LANG_SIMPCHINESE} "OpenAFS for Windows: Simplified Chinese"
   LangString DESC_SecCopyUI ${LANG_TRADCHINESE} "OpenAFS for Windows: Traditional Chinese description"
   LangString DESC_SecCopyUI ${LANG_JAPANESE} "OpenAFS for Windows: Japanese description"
-  ;LangString DESC_SecCopyUI ${LANG_KOREAN} "OpenAFS for Windows: Korean description"
+!ifdef v2.0b4
+  LangString DESC_SecCopyUI ${LANG_KOREAN} "OpenAFS for Windows: Korean description"
+!endif
   ;LangString DESC_SecCopyUI ${LANG_ITALIAN} "OpenAFS for Windows: Italian description"
   ;LangString DESC_SecCopyUI ${LANG_DUTCH} "OpenAFS for Windows: Dutch description"
   ;LangString DESC_SecCopyUI ${LANG_DANISH} "OpenAFS for Windows: Danish description"
   LangString DESC_SecClient ${LANG_SIMPCHINESE} "OpenAFS Client: Allows you to access AFS from your Windows PC."
   LangString DESC_SecClient ${LANG_TRADCHINESE} "OpenAFS Client: Allows you to access AFS from your Windows PC."
   LangString DESC_SecClient ${LANG_JAPANESE} "OpenAFS Client: Allows you to access AFS from your Windows PC."
-  ;LangString DESC_SecClient ${LANG_KOREAN} "OpenAFS Client: Allows you to access AFS from your Windows PC."
+!ifdef v2.0b4  
+  LangString DESC_SecClient ${LANG_KOREAN} "OpenAFS Client: Allows you to access AFS from your Windows PC."
+!endif
   LangString DESC_SecClient ${LANG_PORTUGUESEBR} "OpenAFS Client: Allows you to access AFS from your Windows PC."
   
   LangString DESC_SecServer ${LANG_ENGLISH} "OpenAFS Server: Allows you to run an AFS file server."
   LangString DESC_SecServer ${LANG_SIMPCHINESE} "OpenAFS Server: Allows you to run an AFS file server."
   LangString DESC_SecServer ${LANG_TRADCHINESE} "OpenAFS Server: Allows you to run an AFS file server."
   LangString DESC_SecServer ${LANG_JAPANESE} "OpenAFS Server: Allows you to run an AFS file server."
-  ;LangString DESC_SecServer ${LANG_KOREAN} "OpenAFS Server: Allows you to run an AFS file server."
+!ifdef v2.0b4  
+  LangString DESC_SecServer ${LANG_KOREAN} "OpenAFS Server: Allows you to run an AFS file server."
+!endif
   LangString DESC_SecServer ${LANG_PORTUGUESEBR} "OpenAFS Server: Allows you to run an AFS file server."
   
   LangString DESC_SecControl ${LANG_ENGLISH} "OpenAFS Control Center: GUI utilities for managing and configuring AFS."
   LangString DESC_SecControl ${LANG_SIMPCHINESE} "OpenAFS Control Center: GUI utilities for managing and configuring AFS."
   LangString DESC_SecControl ${LANG_TRADCHINESE} "OpenAFS Control Center: GUI utilities for managing and configuring AFS."
   LangString DESC_SecControl ${LANG_JAPANESE} "OpenAFS Control Center: GUI utilities for managing and configuring AFS."
-  ;LangString DESC_SecControl ${LANG_KOREAN} "OpenAFS Control Center: GUI utilities for managing and configuring AFS."
+!ifdef v2.0b4  
+  LangString DESC_SecControl ${LANG_KOREAN} "OpenAFS Control Center: GUI utilities for managing and configuring AFS."
+!endif
   LangString DESC_SecControl ${LANG_PORTUGUESEBR} "OpenAFS Control Center: GUI utilities for managing and configuring AFS."
   
   LangString DESC_SecDocs ${LANG_ENGLISH} "Supplemental Documentation: Additional documentation for using OpenAFS."
   LangString DESC_SecDocs ${LANG_SIMPCHINESE} "OpenAFS Supplemental Documentation: Additional documentation for using OpenAFS."
   LangString DESC_SecDocs ${LANG_TRADCHINESE} "OpenAFS Supplemental Documentation: Additional documentation for using OpenAFS."
   LangString DESC_SecDocs ${LANG_JAPANESE} "OpenAFS Supplemental Documentation: Additional documentation for using OpenAFS."
-  ;LangString DESC_SecDocs ${LANG_KOREAN} "OpenAFS Supplemental Documentation: Additional documentation for using OpenAFS."
+!ifdef v2.0b4  
+  LangString DESC_SecDocs ${LANG_KOREAN} "OpenAFS Supplemental Documentation: Additional documentation for using OpenAFS."
+!endif
   LangString DESC_SecDocs ${LANG_PORTUGUESEBR} "OpenAFS Supplemental Documentation: Additional documentation for using OpenAFS."
   
 ; Popup error messages
   LangString CellError ${LANG_SIMPCHINESE} "You must specify a valid CellServDB file to copy during the install"
   LangString CellError ${LANG_TRADCHINESE} "You must specify a valid CellServDB file to copy during the install"
   LangString CellError ${LANG_JAPANESE} "You must specify a valid CellServDB file to copy during the install"
-  ;LangString CellError ${LANG_KOREAN} "You must specify a valid CellServDB file to copy during the install"
+!ifdef v2.0b4  
+  LangString CellError ${LANG_KOREAN} "You must specify a valid CellServDB file to copy during the install"
+!endif
   LangString CellError ${LANG_PORTUGUESEBR} "You must specify a valid CellServDB file to copy during the install"
   
   
    LangString UPGRADE_CLIENT ${LANG_SIMPCHINESE} "Upgrade AFS Client"
    LangString UPGRADE_CLIENT ${LANG_TRADCHINESE} "Upgrade AFS Client"
    LangString UPGRADE_CLIENT ${LANG_JAPANESE} "Upgrade AFS Client"
-   ;LangString UPGRADE_CLIENT ${LANG_KOREAN} "Upgrade AFS Client"
+!ifdef v2.0b4
+   LangString UPGRADE_CLIENT ${LANG_KOREAN} "Upgrade AFS Client"
+!endif
    LangString UPGRADE_CLIENT ${LANG_PORTUGUESEBR} "Upgrade AFS Client"
-   
-   
+   LangString REINSTALL_CLIENT ${LANG_ENGLISH} "Re-install AFS Client"
+   LangString REINSTALL_CLIENT ${LANG_GERMAN} "Re-install AFS Client"
+   LangString REINSTALL_CLIENT ${LANG_SPANISH} "Re-install AFS Client"
+   LangString REINSTALL_CLIENT ${LANG_SIMPCHINESE} "Re-install AFS Client"
+   LangString REINSTALL_CLIENT ${LANG_TRADCHINESE} "Re-install AFS Client"
+   LangString REINSTALL_CLIENT ${LANG_JAPANESE} "Re-install AFS Client"
+!ifdef v2.0b4
+   LangString REINSTALL_CLIENT ${LANG_KOREAN} "Re-install AFS Client"
+!endif
+   LangString REINSTALL_CLIENT ${LANG_PORTUGUESEBR} "Re-install AFS Client"
+  
+   LangString UPGRADE_SERVER ${LANG_ENGLISH} "Upgrade AFS Server"
+   LangString UPGRADE_SERVER ${LANG_GERMAN} "Upgrade AFS Server"
+   LangString UPGRADE_SERVER ${LANG_SPANISH} "Upgrade AFS Server"
+   LangString UPGRADE_SERVER ${LANG_SIMPCHINESE} "Upgrade AFS Server"
+   LangString UPGRADE_SERVER ${LANG_TRADCHINESE} "Upgrade AFS Server"
+   LangString UPGRADE_SERVER ${LANG_JAPANESE} "Upgrade AFS Server"
+!ifdef v2.0b4
+   LangString UPGRADE_SERVER ${LANG_KOREAN} "Upgrade AFS Server"
+!endif
+   LangString UPGRADE_SERVER ${LANG_PORTUGUESEBR} "Upgrade AFS Server"
+    
    LangString REINSTALL_SERVER ${LANG_ENGLISH} "Re-install AFS Server"
    LangString REINSTALL_SERVER ${LANG_GERMAN} "Re-install AFS Server"
    LangString REINSTALL_SERVER ${LANG_SPANISH} "Re-install AFS Server"
    LangString REINSTALL_SERVER ${LANG_SIMPCHINESE} "Re-install AFS Server"
    LangString REINSTALL_SERVER ${LANG_TRADCHINESE} "Re-install AFS Server"
    LangString REINSTALL_SERVER ${LANG_JAPANESE} "Re-install AFS Server"
-   ;LangString REINSTALL_SERVER ${LANG_KOREAN} "Re-install AFS Server"
+!ifdef v2.0b4   
+   LangString REINSTALL_SERVER ${LANG_KOREAN} "Re-install AFS Server"
+!endif
    LangString REINSTALL_SERVER ${LANG_PORTUGUESEBR} "Re-install AFS Server"
   
 ;--------------------------------
 Section "AFS Client" SecClient
 
   SetShellVarContext all
+  ; Stop any running services or we can't replace the files
+  ; Stop the running processes
+  ;GetTempFileName $R0
+  ;File /oname=$R0 "${AFS_WININSTALL_DIR}\Killer.exe"   ; Might not have the MSVCR71.DLL file to run
+  ;nsExec::Exec '$R0 afscreds.exe'
+  ;nsExec::Exec '$R0 krbcc32s.exe'
+
+  nsExec::Exec "net stop TransarcAFSDaemon"
+  nsExec::Exec "net stop TransarcAFSServer"
+  
    ; Do client components
   SetOutPath "$INSTDIR\Client\Program"
   File "${AFS_CLIENT_BUILDDIR}\afsshare.exe"
@@ -548,39 +626,15 @@ Section "AFS Client" SecClient
    
    Call AFSLangFiles
    
-   ; Do SYSTEM32 DIR
-   SetOutPath "$SYSDIR"
-   File "${AFS_CLIENT_BUILDDIR}\afs_cpa.cpl"
-!IFDEF DEBUG
-   ;File "${SDK_DIR}\REDIST\msvcrtd.dll"
-   ;File "${SDK_DIR}\REDIST\msvcrtd.pdb"
-!IFDEF CL_1310
-   !insertmacro UpgradeDLL "${AFS_WININSTALL_DIR}\mfc71d.dll" "$SYSDIR\mfc71d.dll"
-!ELSE
-!IFDEF CL_1300
-   !insertmacro UpgradeDLL "${AFS_WININSTALL_DIR}\mfc70d.dll" "$SYSDIR\mfc70d.dll"
-!ELSE
-   !insertmacro UpgradeDLL "${AFS_WININSTALL_DIR}\mfc42d.dll" "$SYSDIR\mfc42d.dll"
-!ENDIF
-!ENDIF
-!ELSE
-   ;File "${SDK_DIR}\REDIST\msvcrt.dll"
-!IFDEF CL_1310
-   !insertmacro UpgradeDLL "${AFS_WININSTALL_DIR}\mfc71.dll" "$SYSDIR\mfc71.dll"
-!ELSE
-!IFDEF CL_1300
-   !insertmacro UpgradeDLL "${AFS_WININSTALL_DIR}\mfc70.dll" "$SYSDIR\mfc70.dll"
-!ELSE
-   !insertmacro UpgradeDLL "${AFS_WININSTALL_DIR}\mfc42.dll" "$SYSDIR\mfc42.dll"
-!ENDIF
-!ENDIF
-!ENDIF
+
    
   ; Do WINDOWSDIR components
   ; Get AFS CellServDB file
   Call afs.GetCellServDB
-  ;Call afs.InstallMSLoopback
-  
+!ifdef INSTALL_LOOPBACK
+  Call afs.InstallMSLoopback
+!endif
+
 !ifdef INSTALL_KFW
   ; Include Kerberos for Windows files in the installer...
   SetOutPath "$INSTDIR\kfw\bin\"
@@ -616,22 +670,22 @@ DontUseFile:
   
   ; AFS Reg entries
   DeleteRegKey HKLM "${AFS_REGKEY_ROOT}\AFS Client\CurrentVersion"
-  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Client\CurrentVersion" "VersionString" ${MUI_VERSION}
+  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Client\CurrentVersion" "VersionString" ${AFS_VERSION}
   WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Client\CurrentVersion" "Title" "AFS Client"
   WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Client\CurrentVersion" "Description" "AFS Client"
   WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Client\CurrentVersion" "PathName" "$INSTDIR\Client\Program"
   WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Client\CurrentVersion" "Software Type" "File System"
-  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Client\CurrentVersion" "MajorVersion" ${MUI_MAJORVERSION}
-  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Client\CurrentVersion" "MinorVersion" ${MUI_MINORVERSION}
-  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Client\CurrentVersion" "PatchLevel" ${MUI_PATCHLEVEL}
-  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Client\${MUI_VERSION}" "VersionString" ${MUI_VERSION}
-  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Client\${MUI_VERSION}" "Title" "AFS Client"
-  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Client\${MUI_VERSION}" "Description" "AFS Client"
-  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Client\${MUI_VERSION}" "Software Type" "File System"
-  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Client\${MUI_VERSION}" "PathName" "$INSTDIR\Client\Program"
-  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Client\${MUI_VERSION}" "MajorVersion" ${MUI_MAJORVERSION}
-  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Client\${MUI_VERSION}" "MinorVersion" ${MUI_MINORVERSION}
-  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Client\${MUI_VERSION}" "PatchLevel" ${MUI_PATCHLEVEL}
+  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Client\CurrentVersion" "MajorVersion" ${AFS_MAJORVERSION}
+  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Client\CurrentVersion" "MinorVersion" ${AFS_MINORVERSION}
+  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Client\CurrentVersion" "PatchLevel" ${AFS_PATCHLEVEL}
+  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Client\${AFS_VERSION}" "VersionString" ${AFS_VERSION}
+  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Client\${AFS_VERSION}" "Title" "AFS Client"
+  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Client\${AFS_VERSION}" "Description" "AFS Client"
+  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Client\${AFS_VERSION}" "Software Type" "File System"
+  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Client\${AFS_VERSION}" "PathName" "$INSTDIR\Client\Program"
+  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Client\${AFS_VERSION}" "MajorVersion" ${AFS_MAJORVERSION}
+  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Client\${AFS_VERSION}" "MinorVersion" ${AFS_MINORVERSION}
+  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Client\${AFS_VERSION}" "PatchLevel" ${AFS_PATCHLEVEL}
 
    ; Set network settings
   WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\NetBT\Parameters" "SmbDeviceEnabled" 0
@@ -680,7 +734,7 @@ skipremove:
   ReadINIStr $R0 $1 "Field 2" "State"
   WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "Cell" $R0
   WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "ShowTrayIcon" 1
-  WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "SecurityLevel" 1  
+  ;WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "SecurityLevel" 1  
   SetRebootFlag true
   
   WriteUninstaller "$INSTDIR\Uninstall.exe"
@@ -692,6 +746,15 @@ SectionEnd
 Section "AFS Server" SecServer
 
   SetShellVarContext all
+  ; Stop any running services or we can't replace the files
+  ; Stop the running processes
+  ;GetTempFileName $R0
+  ;File /oname=$R0 "${AFS_WININSTALL_DIR}\Killer.exe"   ; Might not have the MSVCR71.DLL file to run
+  ;nsExec::Exec '$R0 afscreds.exe'
+  ;nsExec::Exec '$R0 krbcc32s.exe'
+
+  nsExec::Exec "net stop TransarcAFSDaemon"
+  nsExec::Exec "net stop TransarcAFSServer"
 
   CreateDirectory "$INSTDIR\Server\usr\afs\etc"
   CreateDirectory "$INSTDIR\Server\usr\afs\local"
@@ -763,22 +826,22 @@ Section "AFS Server" SecServer
   WriteRegStr HKCU "${AFS_REGKEY_ROOT}\AFS Server" "" $INSTDIR
   
   DeleteRegKey HKLM "${AFS_REGKEY_ROOT}\AFS Server\CurrentVersion"
-  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Server\CurrentVersion" "VersionString" ${MUI_VERSION}
+  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Server\CurrentVersion" "VersionString" ${AFS_VERSION}
   WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Server\CurrentVersion" "Title" "AFS Server"
   WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Server\CurrentVersion" "Description" "AFS Server for Windows"
   WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Server\CurrentVersion" "PathName" "$INSTDIR\Server"
   WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Server\CurrentVersion" "Software Type" "File System"
-  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Server\CurrentVersion" "MajorVersion" ${MUI_MAJORVERSION}
-  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Server\CurrentVersion" "MinorVersion" ${MUI_MINORVERSION}
-  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Server\CurrentVersion" "PatchLevel" ${MUI_PATCHLEVEL}
-  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Server\${MUI_VERSION}" "VersionString" ${MUI_VERSION}
-  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Server\${MUI_VERSION}" "Title" "AFS Server"
-  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Server\${MUI_VERSION}" "Description" "AFS Server for Windows"
-  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Server\${MUI_VERSION}" "Software Type" "File System"
-  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Server\${MUI_VERSION}" "PathName" "$INSTDIR\Server"
-  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Server\${MUI_VERSION}" "MajorVersion" ${MUI_MAJORVERSION}
-  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Server\${MUI_VERSION}" "MinorVersion" ${MUI_MINORVERSION}
-  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Server\${MUI_VERSION}" "PatchLevel" ${MUI_PATCHLEVEL}
+  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Server\CurrentVersion" "MajorVersion" ${AFS_MAJORVERSION}
+  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Server\CurrentVersion" "MinorVersion" ${AFS_MINORVERSION}
+  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Server\CurrentVersion" "PatchLevel" ${AFS_PATCHLEVEL}
+  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Server\${AFS_VERSION}" "VersionString" ${AFS_VERSION}
+  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Server\${AFS_VERSION}" "Title" "AFS Server"
+  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Server\${AFS_VERSION}" "Description" "AFS Server for Windows"
+  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Server\${AFS_VERSION}" "Software Type" "File System"
+  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Server\${AFS_VERSION}" "PathName" "$INSTDIR\Server"
+  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Server\${AFS_VERSION}" "MajorVersion" ${AFS_MAJORVERSION}
+  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Server\${AFS_VERSION}" "MinorVersion" ${AFS_MINORVERSION}
+  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Server\${AFS_VERSION}" "PatchLevel" ${AFS_PATCHLEVEL}
 
   ; Install the service
   SetOutPath "$INSTDIR\Common"
@@ -849,14 +912,14 @@ Section "AFS Control Center" SecControl
    
    ;Store install folder
   WriteRegStr HKCU "${AFS_REGKEY_ROOT}\AFS Control Center\CurrentVersion" "PathName" $INSTDIR
-  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Control Center\CurrentVersion" "VersionString" ${MUI_VERSION}
-  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Control Center\CurrentVersion" "MajorVersion" ${MUI_MAJORVERSION}
-  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Control Center\CurrentVersion" "MinorVersion" ${MUI_MINORVERSION}
-  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Control Center\CurrentVersion" "PatchLevel" ${MUI_PATCHLEVEL}
-  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Control Center\${MUI_VERSION}" "VersionString" ${MUI_VERSION}
-  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Control Center\${MUI_VERSION}" "MajorVersion" ${MUI_MAJORVERSION}
-  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Control Center\${MUI_VERSION}" "MinorVersion" ${MUI_MINORVERSION}
-  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Control Center\${MUI_VERSION}" "PatchLevel" ${MUI_PATCHLEVEL}
+  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Control Center\CurrentVersion" "VersionString" ${AFS_VERSION}
+  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Control Center\CurrentVersion" "MajorVersion" ${AFS_MAJORVERSION}
+  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Control Center\CurrentVersion" "MinorVersion" ${AFS_MINORVERSION}
+  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Control Center\CurrentVersion" "PatchLevel" ${AFS_PATCHLEVEL}
+  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Control Center\${AFS_VERSION}" "VersionString" ${AFS_VERSION}
+  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Control Center\${AFS_VERSION}" "MajorVersion" ${AFS_MAJORVERSION}
+  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Control Center\${AFS_VERSION}" "MinorVersion" ${AFS_MINORVERSION}
+  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Control Center\${AFS_VERSION}" "PatchLevel" ${AFS_PATCHLEVEL}
   
 
   ;Write start menu entries
@@ -878,7 +941,9 @@ Section "Supplemental Documentation" SecDocs
    StrCmp $LANGUAGE ${LANG_GERMAN} DoGerman
    StrCmp $LANGUAGE ${LANG_SPANISH} DoSpanish
    StrCmp $LANGUAGE ${LANG_JAPANESE} DoJapanese
-   ;StrCmp $LANGUAGE ${LANG_KOREAN} DoKorean
+!ifdef v2.0b4
+   StrCmp $LANGUAGE ${LANG_KOREAN} DoKorean
+!endif
    StrCmp $LANGUAGE ${LANG_PORTUGUESEBR} DoPortugueseBR
    StrCmp $LANGUAGE ${LANG_SIMPCHINESE} DoSimpChinese
    StrCmp $LANGUAGE ${LANG_TRADCHINESE} DoTradChinese
@@ -1006,14 +1071,14 @@ DoTradChinese:
 DoneLanguage:
    ;Store install folder
   WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Supplemental Documentation" "" $INSTDIR
-  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Supplemental Documentation\CurrentVersion" "VersionString" ${MUI_VERSION}
-  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Supplemental Documentation\CurrentVersion" "MajorVersion" ${MUI_MAJORVERSION}
-  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Supplemental Documentation\CurrentVersion" "MinorVersion" ${MUI_MINORVERSION}
-  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Supplemental Documentation\CurrentVersion" "PatchLevel" ${MUI_PATCHLEVEL}
-  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Supplemental Documentation\${MUI_VERSION}" "VersionString" ${MUI_VERSION}
-  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Supplemental Documentation\${MUI_VERSION}" "MajorVersion" ${MUI_MAJORVERSION}
-  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Supplemental Documentation\${MUI_VERSION}" "MinorVersion" ${MUI_MINORVERSION}
-  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Supplemental Documentation\${MUI_VERSION}" "PatchLevel" ${MUI_PATCHLEVEL}
+  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Supplemental Documentation\CurrentVersion" "VersionString" ${AFS_VERSION}
+  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Supplemental Documentation\CurrentVersion" "MajorVersion" ${AFS_MAJORVERSION}
+  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Supplemental Documentation\CurrentVersion" "MinorVersion" ${AFS_MINORVERSION}
+  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Supplemental Documentation\CurrentVersion" "PatchLevel" ${AFS_PATCHLEVEL}
+  WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Supplemental Documentation\${AFS_VERSION}" "VersionString" ${AFS_VERSION}
+  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Supplemental Documentation\${AFS_VERSION}" "MajorVersion" ${AFS_MAJORVERSION}
+  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Supplemental Documentation\${AFS_VERSION}" "MinorVersion" ${AFS_MINORVERSION}
+  WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS Supplemental Documentation\${AFS_VERSION}" "PatchLevel" ${AFS_PATCHLEVEL}
 
   ; Write start menu shortcut
   SetOutPath "$SMPROGRAMS\OpenAFS"
@@ -1046,22 +1111,31 @@ Function .onInit
    Abort
    
 contInstall:
+   ; Our logic should be like this.
+   ;     1) If no AFS components are installed, we do a clean install with default options. (Client/Docs)
+   ;     2) If existing modules are installed, we keep them selected
+   ;     3) If it is an upgrade, we set the text accordingly, else we mark it as a re-install
+   ;  TODO: Downgrade?
+   Call IsAnyAFSInstalled
+   Pop $R0
+   StrCmp $R0 "0" DefaultOptions
+   
    Call ShouldClientInstall
    Pop $R2
    
    StrCmp $R2 "0" NoClient
    StrCmp $R2 "2" UpgradeClient
+   StrCmp $R3 "3" DowngradeClient
    
-       StrCpy $1 ${secClient} ; Gotta remember which section we are at now...
        SectionGetFlags ${secClient} $0
        IntOp $0 $0 | ${SF_SELECTED}
        SectionSetFlags ${secClient} $0
     ;# !insertmacro SelectSection ${secClient}
    goto skipClient
 NoClient:
-       StrCpy $1 ${secClient} ; Gotta remember which section we are at now...
+       ;StrCpy $1 ${secClient} ; Gotta remember which section we are at now...
        SectionGetFlags ${secClient} $0
-       IntOp $0 $0 | ${SECTION_OFF}
+       IntOp $0 $0 & ${SECTION_OFF}
        SectionSetFlags ${secClient} $0
    goto skipClient
 UpgradeClient:
@@ -1070,38 +1144,107 @@ UpgradeClient:
        SectionSetFlags ${secClient} $0
    SectionSetText ${secClient} $(UPGRADE_CLIENT)
    goto skipClient
+DowngradeClient:
+       SectionGetFlags ${secClient} $0
+       IntOp $0 $0 | ${SF_SELECTED}
+       SectionSetFlags ${secClient} $0
+   SectionSetText ${secClient} $(REINSTALL_CLIENT)
+   goto skipClient
 
    
 skipClient:   
    
-   
-   Call IsServerInstalled
+   Call ShouldServerInstall
    Pop $R2
    StrCmp $R2 "0" NoServer
+   StrCmp $R2 "2" UpgradeServer
+   StrCmp $R2 "3" DowngradeServer
    
        SectionGetFlags ${secServer} $0
-       IntOp $0 $0 & ${SF_SELECTED}
+       IntOp $0 $0 | ${SF_SELECTED}
        SectionSetFlags ${secServer} $0
        ;# !insertmacro UnselectSection ${secServer}
    goto skipServer
 
+UpgradeServer:
+   SectionGetFlags ${secServer} $0
+   IntOp $0 $0 | ${SF_SELECTED}
+   SectionSetFlags ${secServer} $0
+   SectionSetText ${secServer} $(UPGRADE_SERVER)
+   goto skipServer
+
+DowngradeServer:
+   SectionGetFlags ${secServer} $0
+   IntOp $0 $0 | ${SF_SELECTED}
+   SectionSetFlags ${secServer} $0
+   SectionSetText ${secServer} $(REINSTALL_SERVER)
+   goto skipServer
+   
 NoServer:
        SectionGetFlags ${secServer} $0
        IntOp $0 $0 & ${SECTION_OFF}
        SectionSetFlags ${secServer} $0
        ;# !insertmacro UnselectSection ${secServer}
+   goto skipServer
    
-skipServer:   
+skipServer:
+   ; Check control center
+   Call IsControlInstalled
+   Pop $R2
+   StrCmp $R2 "0" NoControl
+
+       SectionGetFlags ${secControl} $0
+       IntOp $0 $0 | ${SF_SELECTED}
+       SectionSetFlags ${secControl} $0
+   goto CheckDocs
+   
+NoControl:   
        SectionGetFlags ${secControl} $0
        IntOp $0 $0 & ${SECTION_OFF}
        SectionSetFlags ${secControl} $0
        ;# !insertmacro UnselectSection ${secControl}
 
+CheckDocs:
+   ; Check Documentation
+   Call IsDocumentationInstalled
+   Pop $R2
+   StrCmp $R2 "0" NoDocs
+       SectionGetFlags ${secDocs} $0
+       IntOp $0 $0 | ${SF_SELECTED}
+       SectionSetFlags ${secDocs} $0
+   goto end
+   
+NoDocs:
+       SectionGetFlags ${secDocs} $0
+       IntOp $0 $0 & ${SECTION_OFF}
+       SectionSetFlags ${secDocs} $0
+   goto end
+   
+DefaultOptions:
+   ; Client Selected
+       SectionGetFlags ${secClient} $0
+       IntOp $0 $0 | ${SF_SELECTED}
+       SectionSetFlags ${secClient} $0
+
+   ; Server NOT selected
+       SectionGetFlags ${secServer} $0
+       IntOp $0 $0 & ${SECTION_OFF}
+       SectionSetFlags ${secServer} $0
+   
+   ; Control Center NOT selected
+       SectionGetFlags ${secControl} $0
+       IntOp $0 $0 & ${SECTION_OFF}
+       SectionSetFlags ${secControl} $0
+       ;# !insertmacro UnselectSection ${secControl}
+
+   ; Documentation selected
        SectionGetFlags ${secDocs} $0
        IntOp $0 $0 | ${SF_SELECTED}
        SectionSetFlags ${secDocs} $0
        ;# !insertmacro UnselectSection ${secDocs}
+   goto end
 
+end:
        Pop $0
   
   
@@ -1134,12 +1277,20 @@ FunctionEnd
 ;--------------------------------
 ;Descriptions
 
+!ifndef v2.0b4
 !insertmacro MUI_FUNCTIONS_DESCRIPTION_BEGIN
+!else
+!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
+!endif
   !insertmacro MUI_DESCRIPTION_TEXT ${SecServer} $(DESC_SecServer)
   !insertmacro MUI_DESCRIPTION_TEXT ${SecClient} $(DESC_SecClient)
   !insertmacro MUI_DESCRIPTION_TEXT ${SecControl} $(DESC_SecControl)
   !insertmacro MUI_DESCRIPTION_TEXT ${SecDocs} $(DESC_SecDocs)
-!insertmacro MUI_FUNCTIONS_DESCRIPTION_END
+!ifndef v2.0b4
+  !insertmacro MUI_FUNCTIONS_DESCRIPTION_END
+!else
+  !insertmacro MUI_FUNCTION_DESCRIPTION_END
+!endif
  
 ;--------------------------------
 ;Uninstaller Section
@@ -1159,6 +1310,9 @@ Section "Uninstall"
   nsExec::Exec "net stop TransarcAFSDaemon"
   nsExec::Exec "net stop TransarcAFSServer"
   nsExec::Exec '$R0 u TransarcAFSDaemon'
+  ; After we stop the service, but before we delete it, we have to remove the volume data
+  ; This is because the storage locations are in the registry under the service key.
+  ; Call un.RemoveAFSVolumes
   nsExec::Exec '$R0 u TransarcAFSServer'
   Delete $R0
   
@@ -1256,13 +1410,13 @@ Section "Uninstall"
   Delete /REBOOTOK "$INSTDIR\Server\usr\afs\bin\fms.exe"
   Delete /REBOOTOK "$INSTDIR\Server\usr\afs\bin\kaserver.exe"
   Delete /REBOOTOK "$INSTDIR\Server\usr\afs\bin\ptserver.exe"
-  Delete "$INSTDIR\Server\usr\afs\bin\salvager.exe"
+  Delete /REBOOTOK "$INSTDIR\Server\usr\afs\bin\salvager.exe"
   Delete "$INSTDIR\Server\usr\afs\bin\ServerUninst.dll"
-  Delete "$INSTDIR\Server\usr\afs\bin\upclient.exe"
-  Delete "$INSTDIR\Server\usr\afs\bin\upserver.exe"
-  Delete "$INSTDIR\Server\usr\afs\bin\vlserver.exe"
-  Delete "$INSTDIR\Server\usr\afs\bin\volinfo.exe"
-  Delete "$INSTDIR\Server\usr\afs\bin\volserver.exe"
+  Delete /REBOOTOK "$INSTDIR\Server\usr\afs\bin\upclient.exe"
+  Delete /REBOOTOK "$INSTDIR\Server\usr\afs\bin\upserver.exe"
+  Delete /REBOOTOK "$INSTDIR\Server\usr\afs\bin\vlserver.exe"
+  Delete /REBOOTOK "$INSTDIR\Server\usr\afs\bin\volinfo.exe"
+  Delete /REBOOTOK "$INSTDIR\Server\usr\afs\bin\volserver.exe"
 
 !ifdef DEBUG
   Delete /REBOOTOK "$INSTDIR\Server\usr\afs\bin\afskill.pdb"
@@ -1285,6 +1439,7 @@ Section "Uninstall"
 !endif
 
   RMDir /r "$INSTDIR\Server\usr\afs\bin"
+  RmDir /r "$INSTDIR\Server\usr\afs\etc\logs"
   RmDir /r "$INSTDIR\Server\usr\afs\etc"
   RmDir /r "$INSTDIR\Server\usr\afs\local"
   RMDIR /r "$INSTDIR\Server\usr\afs\logs"
@@ -1398,8 +1553,10 @@ Section "Uninstall"
  
   RMDir  "$INSTDIR"
 
+!ifndef v2.0b4
   ;Display the Finish header
   !insertmacro MUI_UNFINISHHEADER
+!endif
 
 SectionEnd
 
@@ -1425,8 +1582,8 @@ FunctionEnd
 Function afs.GetCellServDB
 
 ;Check if we should download CellServDB
-;ReadINIStr $R0 $0 "Field 4" "State"
-;StrCmp $R0 "0" CheckIncl
+ReadINIStr $R0 $0 "Field 4" "State"
+StrCmp $R0 "0" CheckIncl
 
    ReadINIStr $R0 $0 "Field 5" "State"
    NSISdl::download $R0 "$WINDIR\afsdcell.ini"
@@ -1461,6 +1618,14 @@ startOver:
   WriteINIStr $0 "Field 2" "Flags" "DISABLED"
   WriteINIStr $0 "Field 3" "State" "1"
   
+  ; If there is an existing afsdcell.ini file, allow the user to choose it and make it default
+  IfFileExists "$WINDIR\afsdcell.ini" +1 notpresent
+  WriteINIStr $0 "Field 2" "Flags" "ENABLED"
+  WriteINIStr $0 "Field 2" "State" "1"
+  WriteINIStr $0 "Field 3" "State" "3"
+  
+  notpresent:
+  
   !insertmacro MUI_HEADER_TEXT "CellServDB Configuration" "Please choose a method for installing the CellServDB file:" 
   InstallOptions::dialog $0
   Pop $R1
@@ -1506,7 +1671,7 @@ Function AFSCommon.Install
 
 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenAFS" "DisplayName" "OpenAFS for Windows"
 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenAFS" "UninstallString" "$INSTDIR\uninstall.exe"
-WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenAFS" "DisplayVersion" "${MUI_VERSION}"
+WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenAFS" "DisplayVersion" "${AFS_VERSION}"
 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenAFS" "URLInfoAbout" "http://www.openafs.org/"
 
 FunctionEnd
@@ -1586,12 +1751,32 @@ Function GetInstalledVersion
    Push $R1
    Push $R4
    
-   ReadRegDWORD $R0 HKLM "Software\TransarcCorporation\$R2\CurrentVersion" "VersionString"
-   StrCmp $R0 "" NotTransarc
+   ReadRegStr $R0 HKLM "Software\TransarcCorporation\$R2\CurrentVersion" "VersionString"
+   StrCmp $R0 "" NotTransarc done
+   
+   
+NotTransarc:
+   ReadRegStr $R0 HKLM "${AFS_REGKEY_ROOT}\$R2\CurrentVersion" "VersionString"
+   StrCmp $R0 "" done
+   
+done:
+   Pop $R4
+   Pop $R1
+   Exch $R0
+FunctionEnd
+
+; Functions to get each component of the version number
+Function GetInstalledVersionMajor
+   Push $R0
+   Push $R1
+   Push $R4
+   
+   ReadRegDWORD $R0 HKLM "Software\TransarcCorporation\$R2\CurrentVersion" "MajorVersion"
+   StrCmp $R0 "" NotTransarc done
    
    
 NotTransarc:
-   ReadRegDWORD $R0 HKLM "${AFS_REGKEY_ROOT}\$R2\CurrentVersion" "VersionString"
+   ReadRegDWORD $R0 HKLM "${AFS_REGKEY_ROOT}\$R2\CurrentVersion" "MajorVersion"
    StrCmp $R0 "" done
    
 done:
@@ -1600,29 +1785,139 @@ done:
    Exch $R0
 FunctionEnd
 
+Function GetInstalledVersionMinor
+   Push $R0
+   Push $R1
+   Push $R4
+   
+   ReadRegDWORD $R0 HKLM "Software\TransarcCorporation\$R2\CurrentVersion" "MinorVersion"
+   StrCmp $R0 "" NotTransarc done
+   
+   
+NotTransarc:
+   ReadRegDWORD $R0 HKLM "${AFS_REGKEY_ROOT}\$R2\CurrentVersion" "MinorVersion"
+   StrCmp $R0 "" done
+   
+done:
+   Pop $R4
+   Pop $R1
+   Exch $R0
+FunctionEnd
+
+Function GetInstalledVersionPatch
+   Push $R0
+   Push $R1
+   Push $R4
+   
+   ReadRegDWORD $R0 HKLM "Software\TransarcCorporation\$R2\CurrentVersion" "PatchLevel"
+   StrCmp $R0 "" NotTransarc done
+   
+   
+NotTransarc:
+   ReadRegDWORD $R0 HKLM "${AFS_REGKEY_ROOT}\$R2\CurrentVersion" "PatchLevel"
+   StrCmp $R0 "" done
+   
+done:
+   Pop $R4
+   Pop $R1
+   Exch $R0
+FunctionEnd
+
+
 
 ;-------------------------------
 ; Check if the client should be checked for default install
 Function ShouldClientInstall
    Push $R0
-   StrCpy $R2 "Client"
+   StrCpy $R2 "AFS Client"
    Call GetInstalledVersion
    Pop $R0
    
    StrCmp $R0 "" NotInstalled
+   ; Now we see if it's an older or newer version
+
+   Call GetInstalledVersionMajor
+   Pop $R0
+   IntCmpU $R0 ${AFS_MAJORVERSION} +1 Upgrade Downgrade
+
+   Call GetInstalledVersionMinor
+   Pop $R0
+   IntCmpU $R0 ${AFS_MINORVERSION} +1 Upgrade Downgrade
    
-   StrCpy $R0 "0"
+   Call GetInstalledVersionPatch
+   Pop $R0
+   IntCmpU $R0 ${AFS_PATCHLEVEL} Reinstall Upgrade Downgrade
+   
+Reinstall:
+   StrCpy $R0 "1"
+   Exch $R0
+   goto end
+   
+Upgrade:
+   StrCpy $R0 "2"
    Exch $R0
    goto end
    
+Downgrade:
+   StrCpy $R0 "3"
+   Exch $R0
+   goto end
+   
+   
 NotInstalled:
+   StrCpy $R0 "0"
+   Exch $R0
+end:   
+FunctionEnd
+
+;-------------------------------
+; Check how the server options should be set
+Function ShouldServerInstall
+   Push $R0
+   StrCpy $R2 "AFS Server"
+   Call GetInstalledVersion
+   Pop $R0
+   
+   StrCmp $R0 "" NotInstalled
+   ; Now we see if it's an older or newer version
+
+   Call GetInstalledVersionMajor
+   Pop $R0
+   IntCmpU $R0 ${AFS_MAJORVERSION} +1 Upgrade Downgrade
+
+   Call GetInstalledVersionMinor
+   Pop $R0
+   IntCmpU $R0 ${AFS_MINORVERSION} +1 Upgrade Downgrade
+   
+   Call GetInstalledVersionPatch
+   Pop $R0
+   IntCmpU $R0 ${AFS_PATCHLEVEL} Reinstall Upgrade Downgrade
+   
+Reinstall:
    StrCpy $R0 "1"
    Exch $R0
+   goto end
+   
+Upgrade:
+   StrCpy $R0 "2"
+   Exch $R0
+   goto end
+   
+Downgrade:
+   StrCpy $R0 "3"
+   Exch $R0
+   goto end
+   
+   
+NotInstalled:
+   StrCpy $R0 "0"
+   Exch $R0
 end:   
 FunctionEnd
 
 
-; See if AFS Client is installed
+; See if AFS Server is installed
+; Returns: "1" if it is, 0 if it is not (on the stack)
 Function IsServerInstalled
    Push $R0
    StrCpy $R2 "AFS Server"
@@ -1642,7 +1937,8 @@ end:
 FunctionEnd
 
 
-; See if AFS Server is installed
+; See if AFS Client is installed
+; Returns: "1" if it is, 0 if it is not (on the stack)
 Function IsClientInstalled
    Push $R0
    StrCpy $R2 "AFS Client"
@@ -1664,6 +1960,7 @@ FunctionEnd
 
 
 ; See if AFS Documentation is installed
+; Returns: "1" if it is, 0 if it is not (on the stack)
 Function IsDocumentationInstalled
    Push $R0
    StrCpy $R2 "AFS Supplemental Documentation"
@@ -1683,10 +1980,11 @@ end:
 FunctionEnd
 
 
-; See if COntrol Center is installed
+; See if Control Center is installed
+; Returns: "1" if it is, 0 if it is not (on the stack)
 Function IsControlInstalled
    Push $R0
-   StrCpy $R2 "Control_Center"
+   StrCpy $R2 "AFS Control Center"
    Call GetInstalledVersion
    Pop $R0
    
@@ -1735,8 +2033,35 @@ FunctionEnd
 
 
 ;Check to see if any AFS component is installed
+;Returns: Value on stack: "1" if it is, "0" if it is not
 Function IsAnyAFSInstalled
-
+   Push $R0
+   Push $R1
+   Push $R2
+   Push $R3
+   Call IsClientInstalled
+   Pop $R0
+   Call IsServerInstalled
+   Pop $R1
+   Call IsControlInstalled
+   Pop $R2
+   Call IsDocumentationInstalled
+   Pop $R3
+   ; Now we must see if ANY of the $Rn values are 1
+   StrCmp $R0 "1" SomethingInstalled
+   StrCmp $R1 "1" SomethingInstalled
+   StrCmp $R2 "1" SomethingInstalled
+   StrCmp $R3 "1" SomethingInstalled
+   ;Nothing installed
+   StrCpy $R0 "0"
+   goto end
+SomethingInstalled:
+   StrCpy $R0 "1"
+end:
+   Pop $R3
+   Pop $R2
+   Pop $R1
+   Exch $R0
 FunctionEnd
 
 
@@ -1797,7 +2122,9 @@ Function AFSLangFiles
    StrCmp $LANGUAGE ${LANG_GERMAN} DoGerman
    StrCmp $LANGUAGE ${LANG_SPANISH} DoSpanish
    StrCmp $LANGUAGE ${LANG_JAPANESE} DoJapanese
-   ;StrCmp $LANGUAGE ${LANG_KOREAN} DoKorean
+!ifdef v2.0b4
+   StrCmp $LANGUAGE ${LANG_KOREAN} DoKorean
+!endif
    StrCmp $LANGUAGE ${LANG_PORTUGUESEBR} DoPortugueseBR
    StrCmp $LANGUAGE ${LANG_SIMPCHINESE} DoSimpChinese
    StrCmp $LANGUAGE ${LANG_TRADCHINESE} DoTradChinese
@@ -2269,6 +2596,7 @@ Function un.IsNT
     Push 1
 FunctionEnd
 
+!ifdef ADDSHAREDDLLUSED
 ; AddSharedDLL
  ;
  ; Increments a shared DLLs reference count.
@@ -2321,18 +2649,20 @@ FunctionEnd
    Pop $R0
    Pop $R1
  FunctionEnd
+!endif
 
- Function afs.InstallMSLoopback
-   ;GetTempFileName $R0
-   ;File /oname=$R0 "loopback_install.dll"
-   ;nsExec::Exec "rundll32.exe $R0 doLoopBackEntry quiet"
-   ;Call GetWindowsVersion
-   ;Pop $R1
-   ;StrCmp $R1 "2000" +1 +2
-   ;nsExec::Exec "rundll32.exe $R0 disableLoopBackEntry"
-   ;Delete $R0
+!ifdef INSTALL_LOOPBACK
+Function afs.InstallMSLoopback
+   GetTempFileName $R0
+   File /oname=$R0 "loopback_install.dll"
+   nsExec::Exec "rundll32.exe $R0 doLoopBackEntry quiet"
+   Call GetWindowsVersion
+   Pop $R1
+   StrCmp $R1 "2000" +1 +2
+   nsExec::Exec "rundll32.exe $R0 disableLoopBackEntry"
+   Delete $R0
 FunctionEnd
-
+!endif
 
 
 ; GetWindowsVersion