windows 安装程序 (NSIS) 生成应用程序后无法打开应用程序
Unable to Open the application once the windows installer (NSIS) generated the application
我创建了一个 PowerTest.NSI 文件。在此文件中,我包含了所需的 dll 和 exe,如下所示,还添加了所需的
commnads.
File E:\Source\PowerTest.exe
File E:\Source\testutil.dll
File E:\Source\ntutil.dll
我终于加载了这个 NSI 脚本文件,它生成了 PowerTest.exe
我 运行 这个 PowerTest.exe 它生成了下面的 dll 和 exe 以及路径中的卸载 exe (\Program Files\PowerTest)
但是当我运行安装可执行文件时它没有打开应用程序(它没有响应)
完整代码如下:(PowerTest.nsi)
; PowerTest.nsi
;
;
; It will install PowerTest.nsi into a directory that the user selects.
;--------------------------------
; The name of the installer in the path C:\Program Files\PowerTest
Name "UPowerTestPSTest"
; The file to write in the path E:\Source
OutFile "PowerTest.exe"
; The default installation directory in the path C:\Program Files\PowerTest
InstallDir $PROGRAMFILES\PowerTest
; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically) It shows the path the path C:\Program Files\PowerTest
InstallDirRegKey HKLM "Software\PowerTest" "Install_Dir"
; Request application privileges for Windows Vista
RequestExecutionLevel admin
;--------------------------------
; Pages
Page components
Page directory
Page instfiles
UninstPage uninstConfirm
UninstPage instfiles
;--------------------------------
; The stuff to install
Section "PowerTest(required)"
SectionIn RO
DetailPrint "PowerTest"
; Set output path to the installation directory. Here is the path C:\Program Files\PowerTest
SetOutPath $INSTDIR
; Give the dll and exe path
File E:\Source\PowerTest.exe
File E:\Source\testutil.dll
File E:\Source\ntutil.dll
; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\PowerTest"Install_Dir" "$INSTDIR"
; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PowerTest" "DisplayName" "NSIS PowerTest"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PowerTest" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PowerTest" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PowerTest" "NoRepair" 1
WriteUninstaller "uninstall.exe"
SectionEnd
; Optional section (can be disabled by the user)
Section "Start Menu Shortcuts"
CreateDirectory "$SMPROGRAMS\PowerTest"
CreateShortcut "$SMPROGRAMS\PowerTest\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
CreateShortcut "$SMPROGRAMS\PowerTest (MakeNSISW).lnk" "$INSTDIR\PowerTest.nsi" "" "$INSTDIR\PowerTest.nsi" 0
SectionEnd
;--------------------------------
; Uninstaller
Section "Uninstall"
; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PowerTest"
DeleteRegKey HKLM SOFTWARE\PowerTest
; Remove files and uninstaller
Delete $INSTDIR\PowerTest.nsi
Delete $INSTDIR\uninstall.exe
; Remove shortcuts, if any
Delete "$SMPROGRAMS\PowerTest\*.*"
; Remove directories used
RMDir "$SMPROGRAMS\PowerTest"
RMDir "$INSTDIR"
SectionEnd
请让我知道我错过了什么。我们还需要添加任何东西来启动应用程序吗?如果我提供的 .nsi 文本脚本文件有任何更改,请提出建议。
您的 CreateShortcut
调用是错误的,它指向一个 .nsi 文件。它应该指向 $InstDir\PowerTest.exe
.
你的Delete
调用也是错误的,删除一个.nsi没有意义,应该删除你的.exe和.dll文件。
NSIS 不应影响您的应用程序是否正常工作,问题很可能出在其他地方。也许您需要注册 .dll 文件或一些其他配置更改。
我创建了一个 PowerTest.NSI 文件。在此文件中,我包含了所需的 dll 和 exe,如下所示,还添加了所需的 commnads.
File E:\Source\PowerTest.exe
File E:\Source\testutil.dll
File E:\Source\ntutil.dll
我终于加载了这个 NSI 脚本文件,它生成了 PowerTest.exe
我 运行 这个 PowerTest.exe 它生成了下面的 dll 和 exe 以及路径中的卸载 exe (\Program Files\PowerTest)
但是当我运行安装可执行文件时它没有打开应用程序(它没有响应)
完整代码如下:(PowerTest.nsi)
; PowerTest.nsi
;
;
; It will install PowerTest.nsi into a directory that the user selects.
;--------------------------------
; The name of the installer in the path C:\Program Files\PowerTest
Name "UPowerTestPSTest"
; The file to write in the path E:\Source
OutFile "PowerTest.exe"
; The default installation directory in the path C:\Program Files\PowerTest
InstallDir $PROGRAMFILES\PowerTest
; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically) It shows the path the path C:\Program Files\PowerTest
InstallDirRegKey HKLM "Software\PowerTest" "Install_Dir"
; Request application privileges for Windows Vista
RequestExecutionLevel admin
;--------------------------------
; Pages
Page components
Page directory
Page instfiles
UninstPage uninstConfirm
UninstPage instfiles
;--------------------------------
; The stuff to install
Section "PowerTest(required)"
SectionIn RO
DetailPrint "PowerTest"
; Set output path to the installation directory. Here is the path C:\Program Files\PowerTest
SetOutPath $INSTDIR
; Give the dll and exe path
File E:\Source\PowerTest.exe
File E:\Source\testutil.dll
File E:\Source\ntutil.dll
; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\PowerTest"Install_Dir" "$INSTDIR"
; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PowerTest" "DisplayName" "NSIS PowerTest"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PowerTest" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PowerTest" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PowerTest" "NoRepair" 1
WriteUninstaller "uninstall.exe"
SectionEnd
; Optional section (can be disabled by the user)
Section "Start Menu Shortcuts"
CreateDirectory "$SMPROGRAMS\PowerTest"
CreateShortcut "$SMPROGRAMS\PowerTest\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
CreateShortcut "$SMPROGRAMS\PowerTest (MakeNSISW).lnk" "$INSTDIR\PowerTest.nsi" "" "$INSTDIR\PowerTest.nsi" 0
SectionEnd
;--------------------------------
; Uninstaller
Section "Uninstall"
; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PowerTest"
DeleteRegKey HKLM SOFTWARE\PowerTest
; Remove files and uninstaller
Delete $INSTDIR\PowerTest.nsi
Delete $INSTDIR\uninstall.exe
; Remove shortcuts, if any
Delete "$SMPROGRAMS\PowerTest\*.*"
; Remove directories used
RMDir "$SMPROGRAMS\PowerTest"
RMDir "$INSTDIR"
SectionEnd
请让我知道我错过了什么。我们还需要添加任何东西来启动应用程序吗?如果我提供的 .nsi 文本脚本文件有任何更改,请提出建议。
您的 CreateShortcut
调用是错误的,它指向一个 .nsi 文件。它应该指向 $InstDir\PowerTest.exe
.
你的Delete
调用也是错误的,删除一个.nsi没有意义,应该删除你的.exe和.dll文件。
NSIS 不应影响您的应用程序是否正常工作,问题很可能出在其他地方。也许您需要注册 .dll 文件或一些其他配置更改。