试图将INSTALLDIR值更改为$ APPDATA,但不会起作用

时间:2017-12-12 18:03:59

标签: nsis minecraft appdata

我试图让安装程序将一些纹理包和东西提取到AppData文件夹中,但不断更改为程序文件。 (它是为了学校,他们有一个游戏俱乐部,所以我想要着色器和东西。)

############################################################################################
!define APP_NAME "Optifine+"
!define COMP_NAME "Ethan Ginns-Farrow"
!define WEB_SITE "https://www.lennyfaces.net/"
!define VERSION "01.02.00.00"
!define COPYRIGHT "No Copyright Here!"
!define DESCRIPTION "An installer for Optifine and other stuff that I use."
!define LICENSE_TXT "C:\Users\andi1\Desktop\lisense.txt"
!define INSTALLER_NAME "C:\Users\andi1\Desktop\Enon\Junk\Modz\test\Optifine.exe"
!define INSTALL_TYPE "SetShellVarContext current"
!define REG_ROOT "HKCU"
!define UNINSTALL_PATH "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}"

######################################################################

VIProductVersion  "${VERSION}"
VIAddVersionKey "ProductName"  "${APP_NAME}"
VIAddVersionKey "CompanyName"  "${COMP_NAME}"
VIAddVersionKey "LegalCopyright"  "${COPYRIGHT}"
VIAddVersionKey "FileDescription"  "${DESCRIPTION}"
VIAddVersionKey "FileVersion"  "${VERSION}"

######################################################################

SetCompressor LZMA
Name "${APP_NAME}"
Caption "${APP_NAME}"
OutFile "${INSTALLER_NAME}"
BrandingText "${APP_NAME}"
XPStyle on
InstallDirRegKey "${REG_ROOT}" "${UNINSTALL_PATH}" "UninstallString"
InstallDir "$APPDATA\.minecraft"

######################################################################

!include "MUI.nsh"

!define MUI_ABORTWARNING
!define MUI_UNABORTWARNING

!insertmacro MUI_PAGE_WELCOME

!ifdef LICENSE_TXT
!insertmacro MUI_PAGE_LICENSE "${LICENSE_TXT}"
!endif

!insertmacro MUI_PAGE_DIRECTORY

!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_UNPAGE_CONFIRM

!insertmacro MUI_UNPAGE_INSTFILES

!insertmacro MUI_UNPAGE_FINISH

!insertmacro MUI_LANGUAGE "English"

######################################################################

Section -MainProgram
${INSTALL_TYPE}
SetOverwrite ifnewer
SetOutPath "$INSTDIR"
File "C:\Users\andi1\Desktop\Enon\Junk\Modz\MC\Installer\launcher_profiles.json"
File "C:\Users\andi1\Desktop\Enon\Junk\Modz\MC\Installer\options.txt"
File "C:\Users\andi1\Desktop\Enon\Junk\Modz\MC\Installer\optionsshaders.txt"
SetOutPath "$INSTDIR\versions\1.12.2-OptiFine_HD_U_C7"
File "C:\Users\andi1\Desktop\Enon\Junk\Modz\MC\Installer\versions\1.12.2-OptiFine_HD_U_C7\1.12.2-OptiFine_HD_U_C7.jar"
File "C:\Users\andi1\Desktop\Enon\Junk\Modz\MC\Installer\versions\1.12.2-OptiFine_HD_U_C7\1.12.2-OptiFine_HD_U_C7.json"
SetOutPath "$INSTDIR\versions\1.12.2"
File "C:\Users\andi1\Desktop\Enon\Junk\Modz\MC\Installer\versions\1.12.2\1.12.2.jar"
File "C:\Users\andi1\Desktop\Enon\Junk\Modz\MC\Installer\versions\1.12.2\1.12.2.json"
SetOutPath "$INSTDIR\shaderpacks"
File "C:\Users\andi1\Desktop\Enon\Junk\Modz\MC\Installer\shaderpacks\Acid Shaders r6.zip"
File "C:\Users\andi1\Desktop\Enon\Junk\Modz\MC\Installer\shaderpacks\Animal Crossing Shaders r6.zip"
File "C:\Users\andi1\Desktop\Enon\Junk\Modz\MC\Installer\shaderpacks\Sildurs Enhanced Default [redone] v1.01.zip"
File "C:\Users\andi1\Desktop\Enon\Junk\Modz\MC\Installer\shaderpacks\Sildurs Vibrant Shaders v1.166 Extreme-Volumetric Lighting.zip"
File "C:\Users\andi1\Desktop\Enon\Junk\Modz\MC\Installer\shaderpacks\Sildurs Vibrant Shaders v1.166 Extreme.zip"
File "C:\Users\andi1\Desktop\Enon\Junk\Modz\MC\Installer\shaderpacks\Sildurs Vibrant Shaders v1.166 High - Motionblur.zip"
File "C:\Users\andi1\Desktop\Enon\Junk\Modz\MC\Installer\shaderpacks\Sildurs Vibrant Shaders v1.166 Lite.zip"
File "C:\Users\andi1\Desktop\Enon\Junk\Modz\MC\Installer\shaderpacks\Sildurs Vibrant Shaders v1.166 Medium.zip"
SetOutPath "$INSTDIR\resourcepacks"
File "C:\Users\andi1\Desktop\Enon\Junk\Modz\MC\Installer\resourcepacks\Faithful 1.12.2-rv4.zip"
SetOutPath "$INSTDIR\libraries\optifine\OptiFine\1.12.2_HD_U_C7"
File "C:\Users\andi1\Desktop\Enon\Junk\Modz\MC\Installer\libraries\optifine\OptiFine\1.12.2_HD_U_C7\OptiFine-1.12.2_HD_U_C7.jar"
SectionEnd

######################################################################

Section -Icons_Reg
SetOutPath "$INSTDIR"
WriteUninstaller "$INSTDIR\uninstall.exe"

WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}"  "DisplayName" "${APP_NAME}"
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}"  "UninstallString" "$INSTDIR\uninstall.exe"
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}"  "DisplayVersion" "${VERSION}"
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}"  "Publisher" "${COMP_NAME}"

!ifdef WEB_SITE
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}"  "URLInfoAbout" "${WEB_SITE}"
!endif
SectionEnd

######################################################################

Section Uninstall
${INSTALL_TYPE}
Delete "$INSTDIR\launcher_profiles.json"
Delete "$INSTDIR\options.txt"
Delete "$INSTDIR\optionsshaders.txt"
Delete "$INSTDIR\versions\1.12.2-OptiFine_HD_U_C7\1.12.2-OptiFine_HD_U_C7.jar"
Delete "$INSTDIR\versions\1.12.2-OptiFine_HD_U_C7\1.12.2-OptiFine_HD_U_C7.json"
Delete "$INSTDIR\versions\1.12.2\1.12.2.jar"
Delete "$INSTDIR\versions\1.12.2\1.12.2.json"
Delete "$INSTDIR\shaderpacks\Acid Shaders r6.zip"
Delete "$INSTDIR\shaderpacks\Animal Crossing Shaders r6.zip"
Delete "$INSTDIR\shaderpacks\Sildurs Enhanced Default [redone] v1.01.zip"
Delete "$INSTDIR\shaderpacks\Sildurs Vibrant Shaders v1.166 Extreme-Volumetric Lighting.zip"
Delete "$INSTDIR\shaderpacks\Sildurs Vibrant Shaders v1.166 Extreme.zip"
Delete "$INSTDIR\shaderpacks\Sildurs Vibrant Shaders v1.166 High - Motionblur.zip"
Delete "$INSTDIR\shaderpacks\Sildurs Vibrant Shaders v1.166 Lite.zip"
Delete "$INSTDIR\shaderpacks\Sildurs Vibrant Shaders v1.166 Medium.zip"
Delete "$INSTDIR\resourcepacks\Faithful 1.12.2-rv4.zip"
Delete "$INSTDIR\libraries\optifine\OptiFine\1.12.2_HD_U_C7\OptiFine-1.12.2_HD_U_C7.jar"

RmDir "$INSTDIR\libraries\optifine\OptiFine\1.12.2_HD_U_C7"
RmDir "$INSTDIR\resourcepacks"
RmDir "$INSTDIR\shaderpacks"
RmDir "$INSTDIR\versions\1.12.2"
RmDir "$INSTDIR\versions\1.12.2-OptiFine_HD_U_C7"

Delete "$INSTDIR\uninstall.exe"
!ifdef WEB_SITE
Delete "$INSTDIR\${APP_NAME} website.url"
!endif

RmDir "$INSTDIR"

DeleteRegKey ${REG_ROOT} "${UNINSTALL_PATH}"
SectionEnd

######################################################################

我需要改变什么?

编辑:嗯......它突然开始工作了。我尝试使用测试按钮而不是EXE来运行它。我不知道它是如何刹车的,这可能让我听起来很愚蠢,但那就是发生了什么。

1 个答案:

答案 0 :(得分:0)

如果没有更多信息,很难说明发生了什么,但我建议您在脚本中添加RequestExecutionLevel User,以确保Windows不会向安装程序应用兼容性填充程序。

如果您在计算机上进行测试期间安装了Program Files,

InstallDirRegKey会欺骗您。调试此类问题时,请确保注册表中不存在该值。