我创建了一个 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,它在路径 (\Program Files\PowerTest) 中生成了以下 dll 和 exe 以及卸载 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 文本脚本文件是否有任何更改。
你的CreateShortcut
调用是错误的,它指向一个 .nsi 文件。它应该指向$InstDir\PowerTest.exe
.
您的Delete
调用也是错误的,删除 .nsi 没有意义,它应该删除您的 .exe 和 .dll 文件。
NSIS 不应该对您的应用程序是否有效产生影响,问题很可能出在其他地方。也许您需要注册 .dll 文件或其他一些配置更改。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句