我已经创建了一个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,以及路径(\Program Files\PowerTest)中的uninstall exe。
但是当我运行可执行文件时,它没有打开应用程序(它没有响应)
下面是完整的代码:(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文本脚本文件有任何更改,请提出建议。
发布于 2018-10-12 08:40:10
您的CreateShortcut
调用错误,它指向.nsi文件。它应该指向$InstDir\PowerTest.exe
。
您的Delete
调用也是错误的,删除.nsi没有任何意义,它应该删除您的.exe和.dll文件。
无论您的应用程序是否工作,NSIS都不应该造成影响,问题很可能出在其他地方。也许您需要注册.dll文件或其他一些配置更改。
https://stackoverflow.com/questions/52758402
复制相似问题