我一直在使用NSIS
来获取win form应用程序来创建Windows安装程序。最近,我的一位测试人员报告了一个错误,即NSIS已停止在Program Files (x86)
中创建多个文件夹。
我们之前在多个环境(Staging,Prep.,Production
)上工作我能够为环境中的每个环境创建安装程序但最近我认为Program Files (x86)
中的文件被覆盖了。
以下是方案:
我为登台环境创建了一个安装程序。一切顺利,文件安装在Program Files (x86)
,桌面图标被创建,应用程序被添加到启动菜单我能够运行,一切看起来都不错
现在我正在尝试为Pre-Production环境创建一个安装程序。在编译NSIS
脚本并测试安装程序后,目标文件夹没有被覆盖,它正在采用相同的路径进行staging.Still,继续安装程序,这就是正在发生的事情。
没有在Program Files (x86)
创建新文件夹。我只有暂存文件夹。
将创建一个新的桌面图标,但是当我运行暂存应用程序时,预生产正在运行
卸载Staging应用程序将卸载环境
我不知道我附加了NSIS
脚本发生了什么。请看看它,让我知道我做错了什么。
谢谢你的问候
以下是NSIS脚本:
; Script generated by the HM NIS Edit Script Wizard.
; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "iContracts staging - Bulk Contract Uploader v 7.9"
!define DIR_NAME "icontracts-UCO-BulkLoader-staging"
!define PRODUCT_VERSION ""
!define PRODUCT_PUBLISHER "iContracts"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\UCO\IcnBulkUpload.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\UCO\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
; MUI 1.67 compatible ------
!include "MUI.nsh"
; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON ".\Images\mine.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
; Welcome page
;!insertmacro MUI_PAGE_WELCOME
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define MUI_FINISHPAGE_RUN "$INSTDIR\IcnBulkUpload.exe"
!insertmacro MUI_PAGE_FINISH
; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES
; Language files
!insertmacro MUI_LANGUAGE "English"
; MUI end ------
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "${PRODUCT_NAME}.exe"
;InstallDir "$PROGRAMFILES\${PRODUCT_NAME}"
InstallDir "$PROGRAMFILES\${DIR_NAME}"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show
Function GetDotNet
IfFileExists "$WINDIR\Microsoft.NET\Framework\v2.0.50727\installUtil.exe" NextStep
MessageBox MB_OK|MB_ICONEXCLAMATION "You must have the Microsoft .NET Framework 2.0 Installed to use this application. $\n$\nClick 'Open' in the following file dialog to download and run the Microsoft .NET Framework Installer..."
ExecShell Open "http://www.microsoft.com/downloads/info.aspx?na=90&p=&SrcDisplayLang=en&SrcCategoryId=&SrcFamilyId=0856eacb-4362-4b0d-8edd-aab15c5e04f5&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2f5%2f6%2f7%2f567758a3-759e-473e-bf8f-52154438565a%2fdotnetfx.exe" SW_SHOWNORMAL
Quit
NextStep:
FunctionEnd
Section "Check Dot Net" SEC02
Call GetDotNet
SectionEnd
Section "MainSection" SEC01
SetOutPath "$INSTDIR"
SetOverwrite on
File ".\bin\Debug\IcnBulkUpload.exe"
File ".\bin\Debug\IcnBulkUpload.exe.config"
File ".\mine.ICO"
CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk" "$INSTDIR\IcnBulkUpload.exe" "" "$INSTDIR\mine.ICO"
CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\IcnBulkUpload.exe" "" "$INSTDIR\mine.ICO"
; CreateDirectory ""
CreateShortCut "$STARTMENU.lnk" "$INSTDIR\IcnBulkUpload.exe"
SectionEnd
Section -AdditionalIcons
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd
Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\IcnBulkUpload.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\IcnBulkUpload.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd
Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
FunctionEnd
Function un.onInit
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
Abort
FunctionEnd
Section Uninstall
Delete "$INSTDIR\uninst.exe"
Delete "$INSTDIR\IcnBulkUpload.exe"
Delete "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall.lnk"
Delete "$STARTMENU.lnk"
Delete "$DESKTOP\iContracts.lnk"
Delete "$SMPROGRAMS\${PRODUCT_NAME}\iContracts.lnk"
RMDir /r "$SMPROGRAMS\${PRODUCT_NAME}"
RMDir /r "$INSTDIR"
RMDir ""
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
SetAutoClose true
SectionEnd
答案 0 :(得分:0)
InstallDirRegKey
属性如果找到现有安装,则会更改$InstDir
!对每种安装类型使用PRODUCT_UNINST_KEY的唯一值,并将其用作InstallDirRegKey
使用的路径。