博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
nisi 脚本示例
阅读量:5134 次
发布时间:2019-06-13

本文共 3399 字,大约阅读时间需要 11 分钟。

只是简单的copy文件和添加快捷方式,安装和卸载时对程序是否运行进行检测

;--------------------------------;Include Modern UI  !include "MUI2.nsh";--------------------------------;Interface Settings  !define MUI_ABORTWARNING  !define PRODUCT_UNINST_KEY "Software/Microsoft/Windwos/CurrentVersion/Uninstall/AppName"  !define SOURCE_DIR "G:/emulator"  ;--------------------------------;General  ;Name and file  Name "AppName"  OutFile "AppNameSetup.exe"  ;Default installation folder  InstallDir "C:\AppName"  Icon "${SOURCE_DIR}/App.ico"  ;UninstallIcon "App.ico"  UninstallCaption "uninstall AppName"  ;Get installation folder from registry if available  InstallDirRegKey HKCU "Software\AppName" ""  ;Request application privileges for Windows Vista  RequestExecutionLevel admin;--------------------------------;Pages  !define MUI_ICON "${SOURCE_DIR}/App.ico"  !define MUI_UNICON "${SOURCE_DIR}/App.ico"  ;!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt"  ;!insertmacro MUI_PAGE_COMPONENTS  !insertmacro MUI_PAGE_DIRECTORY  !insertmacro MUI_PAGE_INSTFILES    !insertmacro MUI_UNPAGE_WELCOME  !insertmacro MUI_UNPAGE_CONFIRM  !insertmacro MUI_UNPAGE_INSTFILES  !insertmacro MUI_UNPAGE_FINISH  ;--------------------------------;Languages   !insertmacro MUI_LANGUAGE "SimpChinese";--------------------------------;Installer SectionsFunction .onInit  ;检测程序是否运行  FindProcDLL::FindProc "AppName.exe"   Pop $R0   IntCmp $R0 1 0 no_run   MessageBox MB_ICONSTOP "安装程序检测到 AppName 正在运行,请关闭之后再进行安装!"   Quit   no_run:FunctionEndSection ""  SetOutPath "$INSTDIR"    ;ADD YOUR OWN FILES HERE...  File /r "*"  Delete "AppName.nsi"  Delete "AppSetup.exe"    ;Store installation folder  WriteRegStr HKCU "Software\AppName" "AppName" "$INSTDIR\AppName.exe"    ;Create uninstaller  WriteUninstaller "$INSTDIR\Uninstall.exe"    CreateShortCut "$DESKTOP\AppName.lnk" "$INSTDIR\AppName.exe"  CreateShortCut "$SMPROGRAMS\AppName.lnk" "$INSTDIR\AppName.exe"  CreateShortCut "$SMPROGRAMS\uninstall AppName.lnk" "$INSTDIR\Uninstall.exe"  ;CreateShortCut "$QUICKLAUNCH\AppName.lnk" "$INSTDIR\AppName.exe"SectionEndSection -Post    WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AppName" "DisplayIcon" "${SOURCE_DIR}/AppName.ico"  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AppName" "Publisher" "3g2win"  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AppName" "DisplayName" "AppName"  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AppName" "DisplayVersion " "1.0.0"  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AppName" "UninstallString" "$INSTDIR\Uninstall.exe"SectionEnd;--------------------------------;Uninstaller SectionFunction un.onInit  ;检测程序是否运行  FindProcDLL::FindProc "AppName.exe"   Pop $R0   IntCmp $R0 1 0 no_run   MessageBox MB_ICONSTOP "卸载程序检测到 AppName正在运行,请关闭之后再卸载!"   Quit   no_run:FunctionEndSection "Uninstall"  ;ADD YOUR OWN FILES HERE...  Delete "$INSTDIR\Uninstall.exe"  RMDir /r "$INSTDIR"  Delete "$DESKTOP\AppName.lnk"  Delete "$SMPROGRAMS\AppName.lnk"  Delete "$SMPROGRAMS\uninstall AppName.lnk"    DeleteRegKey /ifempty HKCU "Software\AppName\AppName"  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AppName"  ;SetAutoClose trueSectionEnd

AppExample.nsi.rar

参考

NSIS:安装、卸载时检查程序是否正在运行

NSIS 安装脚本(备忘)

[已解决] 卸载时注册表键无法删除,很奇怪

转载于:https://www.cnblogs.com/grj1046/p/3566516.html

你可能感兴趣的文章
数组的创建及使用
查看>>
Vagrant安装完lnmp后,配置linux和windows共享文件并配置虚拟主机访问项目
查看>>
C#多线程那点事——信号量(Semaphore) Semaphore 信号量
查看>>
浏览器的线程有哪些
查看>>
PyTorch 实现kmax-pooling
查看>>
数据库点滴积累——查询
查看>>
将 Excel 导入到 SharePoint 列表
查看>>
C#中的yield关键字
查看>>
PHP获取中英文混合字符串长度及截取
查看>>
uva 11584 Partitioning by Palindromes(dp)
查看>>
面试题学习总结--三
查看>>
leetcode简单题目两道(5)
查看>>
(1)数据结构——线性表(数组)实现
查看>>
Content Providers的步骤,来自官网文档
查看>>
sql语句中的 inner join 、 left join 、 right join、 full join 的区别
查看>>
手动实现枚举器、泛型集合、单链表
查看>>
java反序列化漏洞原理研习
查看>>
LeetCode Algorithm 07_Reverse Integer
查看>>
PrintWriter、PrintStream的苦头 ------缓冲区问题
查看>>
第二张 例2.4
查看>>