我有一个以管理员身份登录的Windows 7系统,我无法安装到根目录(c:\ MyAPP)。如果我为所有用户安装它将文件放在C:\ Program Files(x86)\ C \ MyAPP中。如果我为单个用户安装,它会将文件放在该用户应用程序数据目录中或类似的位置。我将AllowRootDirInstall设置为true。我在错误报告中发现了一个假想的工作。
CreateDirectory $INSTDIR
StrCpy $OUTDIR $INSTDIR
甚至没有说出把它放在哪里所以我把它放在主要部分的顶部。
我缺少什么想法?
NSIS脚本
# 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
答案 0 :(得分:1)
来自文档:MULTIUSER_INSTALLMODE_INSTDIR:
安装应用程序的文件夹的名称,没有 路径即可。此文件夹将位于每台计算机的Program Files中 安装并在每个用户的本地Application Data文件夹中 安装
如果您总是想要安装到root用户,则根本不应该使用MultiUser,因为只有管理员才能写入驱动器的根目录...
答案 1 :(得分:0)
我的解决方案是从NSIS切换到Inno Setup with istool,如
中接受的答案所示构建Windows安装程序的最佳选择是什么?
到目前为止,我可以安装到c:\ MyApp,我安装了最新版本的jre。