Reputation: 891
I have a windows 7 system logged in as an administrator and I am unable to install to the root directory (c:\MyAPP). If I install for all users it puts the file in C:\Program Files (x86)\C\MyAPP. If I install for a single user it places the file in that users application data directory or something like that. I have AllowRootDirInstall set to true. I found a supposed work around in a bug report.
CreateDirectory $INSTDIR
StrCpy $OUTDIR $INSTDIR
Didn't even say where to put it so I just placed it at the top of the main section.
Any ideas of what I am missing?
NSIS Script
# Auto-generated by EclipseNSIS Script Wizard
# 28-May-2013 2:27:56 PM
Name MyApplication
# General Symbol Definitions
!define REGKEY "SOFTWARE\$(^Name)"
!define VERSION 1.0
!define COMPANY mycompany
!define URL http://mycompany.com
# MultiUser Symbol Definitions
!define MULTIUSER_EXECUTIONLEVEL Highest
!define MULTIUSER_INSTALLMODE_DEFAULT_CURRENTUSER
!define MULTIUSER_MUI
!define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY "${REGKEY}"
!define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME MultiUserInstallMode
!define MULTIUSER_INSTALLMODE_COMMANDLINE
!define MULTIUSER_INSTALLMODE_INSTDIR C:\MyAPP
!define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY "${REGKEY}"
!define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUE "Path"
# MUI Symbol Definitions
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_UNFINISHPAGE_NOAUTOCLOSE
# Included files
!include MultiUser.nsh
!include Sections.nsh
!include MUI2.nsh
# Variables
Var StartMenuGroup
# Installer pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MULTIUSER_PAGE_INSTALLMODE
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
# Installer languages
!insertmacro MUI_LANGUAGE English
# Installer attributes
OutFile myapp-1.0-installer.exe
InstallDir "C:\MyAPP"
CRCCheck on
XPStyle on
ShowInstDetails show
AllowRootDirInstall true
VIProductVersion 1.0.0.0
VIAddVersionKey ProductName Proshots
VIAddVersionKey ProductVersion "${VERSION}"
VIAddVersionKey CompanyName "${COMPANY}"
VIAddVersionKey CompanyWebsite "${URL}"
VIAddVersionKey FileVersion "${VERSION}"
VIAddVersionKey FileDescription ""
VIAddVersionKey LegalCopyright ""
InstallDirRegKey HKLM "${REGKEY}" Path
ShowUninstDetails hide
# Installer sections
Section -Main SEC0000
CreateDirectory $INSTDIR
StrCpy $OUTDIR $INSTDIR
SetOutPath $INSTDIR
SetOverwrite off
File subjects.xml
File messages.xml
SetOverwrite on
File myapp-run.bat
SetOutPath $SMPROGRAMS\$StartMenuGroup
CreateShortcut $SMPROGRAMS\$StartMenuGroup\MyAPP.lnk $INSTDIR\myapp-run.bat
SetOutPath $INSTDIR
File C:\fotonow-working\myapp.jar
WriteRegStr HKLM "${REGKEY}\Components" Main 1
SectionEnd
Section -post SEC0001
WriteRegStr HKLM "${REGKEY}" Path $INSTDIR
SetOutPath $INSTDIR
WriteUninstaller $INSTDIR\uninstall.exe
SetOutPath $SMPROGRAMS\$StartMenuGroup
CreateShortcut "$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk" $INSTDIR\uninstall.exe
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayVersion "${VERSION}"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Publisher "${COMPANY}"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" URLInfoAbout "${URL}"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayIcon $INSTDIR\uninstall.exe
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\uninstall.exe
WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1
WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1
SectionEnd
# Macro for selecting uninstaller sections
!macro SELECT_UNSECTION SECTION_NAME UNSECTION_ID
Push $R0
ReadRegStr $R0 HKLM "${REGKEY}\Components" "${SECTION_NAME}"
StrCmp $R0 1 0 next${UNSECTION_ID}
!insertmacro SelectSection "${UNSECTION_ID}"
GoTo done${UNSECTION_ID}
next${UNSECTION_ID}:
!insertmacro UnselectSection "${UNSECTION_ID}"
done${UNSECTION_ID}:
Pop $R0
!macroend
# Uninstaller sections
Section /o -un.Main UNSEC0000
Delete /REBOOTOK $INSTDIR\myapp.jar
Delete /REBOOTOK $SMPROGRAMS\$StartMenuGroup\MyAPP.lnk
Delete /REBOOTOK $INSTDIR\myapp-run.bat
Delete /REBOOTOK $INSTDIR\messages.xml
Delete /REBOOTOK $INSTDIR\subjects.xml
DeleteRegValue HKLM "${REGKEY}\Components" Main
SectionEnd
Section -un.post UNSEC0001
DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk"
Delete /REBOOTOK $INSTDIR\uninstall.exe
DeleteRegValue HKLM "${REGKEY}" Path
DeleteRegKey /IfEmpty HKLM "${REGKEY}\Components"
DeleteRegKey /IfEmpty HKLM "${REGKEY}"
RmDir /REBOOTOK $SMPROGRAMS\$StartMenuGroup
RmDir /REBOOTOK $INSTDIR
SectionEnd
# Installer functions
Function .onInit
InitPluginsDir
StrCpy $StartMenuGroup MyAPP
!insertmacro MULTIUSER_INIT
FunctionEnd
# Uninstaller functions
Function un.onInit
StrCpy $StartMenuGroup MyAPP
!insertmacro MULTIUSER_UNINIT
!insertmacro SELECT_UNSECTION Main ${UNSEC0000}
FunctionEnd
Upvotes: 0
Views: 1764
Reputation: 101606
From the docs: MULTIUSER_INSTALLMODE_INSTDIR:
Name of the folder in which to install the application, without a path. This folder will be located in Program Files for a per-machine installation and in the local Application Data folder for a per-user installation
If you always want to install to the root you should not be using MultiUser at all since only administrators can write to the root of a drive...
Upvotes: 1
Reputation: 891
My solution was to switch from NSIS to Inno Setup with istool as suggest in the accepted answer of
What is the best choice for building Windows installers?
So far so good, I can install to c:\MyApp and I have the installer installing the newest version of jre.
Upvotes: 0