NSIS Installer: Selecting an install directory is now idiot proof.

git-svn-id: svn://svn.jdownloader.org/jdownloader/trunk@12861 ebf7c1c2-ba36-0410-9fe8-c592906822b4
This commit is contained in:
scr4ve 2010-11-03 20:40:41 +00:00
parent 2d5850822b
commit f667bc019a
2 changed files with 53 additions and 2 deletions

View File

@ -82,9 +82,58 @@ done${UNSECTION_ID}:
${EndIf}
${EndIf}
UninstDirFound:
!insertmacro evilDirCheck
!macroend
###
!macro evilDirCheck
#According to http://nsis.sourceforge.net/Validating_$INSTDIR_before_uninstall
#Check a huge bunch of NSIS variables, also.
StrCpy $R0 $INSTDIR ""
StrCmp $R0 $APPDATA evilDirCheck_bad
StrCmp $R0 $COMMONFILES evilDirCheck_bad
StrCmp $R0 $COMMONFILES32 evilDirCheck_bad
StrCmp $R0 $COMMONFILES64 evilDirCheck_bad
StrCmp $R0 $DESKTOP evilDirCheck_bad
StrCmp $R0 $DOCUMENTS evilDirCheck_bad
StrCmp $R0 $LOCALAPPDATA evilDirCheck_bad
StrCmp $R0 $MUSIC evilDirCheck_bad
StrCmp $R0 $PICTURES evilDirCheck_bad
StrCmp $R0 $PROFILE evilDirCheck_bad
StrCmp $R0 $PROGRAMFILES evilDirCheck_bad
StrCmp $R0 $PROGRAMFILES32 evilDirCheck_bad
StrCmp $R0 $PROGRAMFILES64 evilDirCheck_bad
StrCmp $R0 $SYSDIR evilDirCheck_bad
StrCmp $R0 $VIDEOS evilDirCheck_bad
StrCmp $R0 $WINDIR evilDirCheck_bad
StrCmp $R0 "" evilDirCheck_bad
StrCpy $R0 $INSTDIR "" -2
StrCmp $R0 ":\" evilDirCheck_bad
StrCpy $R0 $INSTDIR "" -14
StrCmp $R0 "\Program Files" evilDirCheck_bad
StrCpy $R0 $INSTDIR "" -8
StrCmp $R0 "\Windows" evilDirCheck_bad
StrCpy $R0 $INSTDIR "" -6
StrCmp $R0 "\WinNT" evilDirCheck_bad
StrCpy $R0 $INSTDIR "" -9
StrCmp $R0 "\system32" evilDirCheck_bad
StrCpy $R0 $INSTDIR "" -8
StrCmp $R0 "\Desktop" evilDirCheck_bad
StrCpy $R0 $INSTDIR "" -22
StrCmp $R0 "\Documents and Settings" evilDirCheck_bad
StrCpy $R0 $INSTDIR "" -13
StrCmp $R0 "\My Documents" evilDirCheck_bad evilDirCheck_done
evilDirCheck_bad:
MessageBox MB_OK|MB_ICONSTOP "Install path invalid!"
Abort
evilDirCheck_done:
!macroend
Function dirLeave
!insertmacro evilDirCheck
FunctionEnd
###This function removes a dir recursively except one of its subdirs
Function un.RmButOne
Exch $R0 ; exclude dir

View File

@ -36,6 +36,7 @@ SetCompressor lzma
!define VERSION2 1.0.0.0
# Just don't edit below this line.
InstallDir "$PROGRAMFILES\${APPNAME_SHORT}" #Necessary for correct append behaviour on user selection
!define INSTDIR_USER "$PROFILE\${APPNAME_SHORT}"
!define INSTDIR_ADMIN "$PROGRAMFILES\${APPNAME_SHORT}"
!define REGKEY "Software\${APPNAME_SHORT}"
@ -50,7 +51,7 @@ SetCompressor lzma
# Java Check
!define JRE_VERSION "1.6"
!define JRE_SILENT 0
!define JRE_URL "http://javadl.sun.com/webapps/download/AutoDL?BundleId=39502"
!define JRE_URL "http://javadl.sun.com/webapps/download/AutoDL?BundleId=42746"
# Included files
!AddPluginDir plugins
@ -70,7 +71,8 @@ Var ADMINATINSTALL
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE ${LICENSE}
#!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE dirLeave
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro CUSTOM_PAGE_JREINFO
!insertmacro ADVERTISING_PAGE
!insertmacro MUI_PAGE_INSTFILES