2013-05-29 127 views
0

我有一個Windows 7系統以管理員身份登錄,我無法安裝到根目錄(c:\ MyAPP)。如果我爲所有用戶安裝,它將文件放在C:\ Program Files(x86)\ C \ MyAPP中。如果我爲單個用戶安裝,則會將該文件放入該用戶應用程序數據目錄中或類似的東西。我將AllowRootDirInstall設置爲true。我在bug報告中發現了一個假想的工作。無法安裝應用程序到NSIS根目錄

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 

回答

1

從文檔:MULTIUSER_INSTALLMODE_INSTDIR:

中安裝應用程序,沒有 路徑的文件夾名稱。此文件夾將位於Program Files的每臺機器 安裝在本地應用程序數據文件夾中的每個用戶 安裝

如果你總是要安裝到您不應該使用多用戶的根因爲只有管理員可以寫入驅動器的根...

+0

謝謝,爲我解決它。由於應用程序基本上對文件進行排序,所以需要在包括安裝目錄在內的目錄上編寫適當的權限,因此Windows問題的UAC設置加劇了我的問題。我可以將配置文件移動到另一個目錄,但這不是客戶想要的。 – Codeguy007

0

我的解決辦法是從NSIS切換到Inno Setup with istool如在

什麼是構建Windows安裝程序的最佳選擇接受的答案建議?

到目前爲止,我可以安裝到c:\ MyApp,並且安裝了最新版本的jre。

相關問題