I'm trying to make an installer to extract some texture packs and stuff into the AppData folder, but keeps changing to program files.
############################################################################################
!define APP_NAME "Optifine+"
!define COMP_NAME "SquirrelKiev"
!define WEB_SITE "https://www.lennyfaces.net/"
!define VERSION "01.02.00.00"
!define COPYRIGHT ""
!define DESCRIPTION "An installer for Optifine and other stuff that I use."
!define LICENSE_TXT "C:\Users\User\Desktop\lisense.txt"
!define INSTALLER_NAME "C:\Users\User\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\User\Desktop\MCInstaller\launcher_profiles.json"
File "C:\Users\User\Desktop\MCInstaller\options.txt"
File "C:\Users\User\Desktop\MCInstaller\optionsshaders.txt"
SetOutPath "$INSTDIR\versions\1.12.2-OptiFine_HD_U_C7"
File "C:\Users\User\Desktop\MCInstaller\versions\1.12.2-OptiFine_HD_U_C7\1.12.2-OptiFine_HD_U_C7.jar"
File "C:\Users\User\Desktop\MCInstaller\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\User\Desktop\MCInstaller\versions\1.12.2\1.12.2.jar"
File "C:\Users\User\Desktop\MCInstaller\versions\1.12.2\1.12.2.json"
SetOutPath "$INSTDIR\shaderpacks"
File "C:\Users\User\Desktop\MCInstaller\shaderpacks\Acid Shaders r6.zip"
File "C:\Users\User\Desktop\MCInstaller\shaderpacks\Animal Crossing Shaders r6.zip"
File "C:\Users\User\Desktop\MCInstaller\shaderpacks\Sildurs Enhanced Default [redone] v1.01.zip"
File "C:\Users\User\Desktop\MCInstaller\shaderpacks\Sildurs Vibrant Shaders v1.166 Extreme-Volumetric Lighting.zip"
File "C:\Users\User\Desktop\MCInstaller\shaderpacks\Sildurs Vibrant Shaders v1.166 Extreme.zip"
File "C:\Users\User\Desktop\MCInstaller\shaderpacks\Sildurs Vibrant Shaders v1.166 High - Motionblur.zip"
File "C:\Users\User\Desktop\MCInstaller\shaderpacks\Sildurs Vibrant Shaders v1.166 Lite.zip"
File "C:\Users\User\Desktop\MCInstaller\shaderpacks\Sildurs Vibrant Shaders v1.166 Medium.zip"
SetOutPath "$INSTDIR\resourcepacks"
File "C:\Users\User\Desktop\MCInstaller\resourcepacks\Faithful 1.12.2-rv4.zip"
SetOutPath "$INSTDIR\libraries\optifine\OptiFine\1.12.2_HD_U_C7"
File "C:\Users\User\Desktop\MCInstaller\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
######################################################################
What do I need to change?
EDIT: Hmm... It's suddenly started working. I tried running it using the test button instead of the EXE. I don't know how that breaks it, and that probably makes me sound stupid, but thats what happened.
Without more information it is hard to say what is going on but I would recommend that you add RequestExecutionLevel User
to your script to make sure Windows does not apply compatibility shims to the installer.
InstallDirRegKey
can trick you if you installed to Program Files during testing on your machine. Make sure that value is not present in the registry when debugging issues like this.