Qt NSIS 常用指令

1,静默安装

SilentInstall silent 
SilentUninstall silent 
比如:
SilentInstall silent 
SilentUninstall silent 
Section "MainSection" SEC01
  SetOutPath "$INSTDIR"
  SetOverwrite try
  File "path_1.0.1\Video.exe"
SectionEnd

2,安装后运行 指定程序

Function .onInstSuccess
ExecShell "" "$INSTDIR\Video.exe"
FunctionEnd

3,安装后 开机自启

WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Run""Video" "$INSTDIR\Video.exe" ; 开机自启

DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "Video" ;卸载开机启动

4,杀死进程

需要下载插件  https://www.cnblogs.com/chechen/p/11125353.html

Function .onInit
KillProcDLL::KillProc "Video.exe" ;杀进程
Sleep 1000
FunctionEnd 

某些进程杀不掉 用这个:

Function .onInit
ExecCmd::exec '"taskkill" /F /IM hiclass.exe /T'
FunctionEnd

5,管理员运行

WriteRegStr HKCU "Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" "$INSTDIR\Video.exe" "RUNASADMIN" ;管理员运行 

6,

; 安装VC环境
Function .onInstSuccess
   Push $R0
   ClearErrors
   ReadRegStr $R0 HKLM "SOFTWARE\Classes\Installer\Dependencies\{e2803110-78b3-4664-a479-3611a381656a}" "Version"

   ; 检测含有vc的注册表信息是否存在
   IfErrors 0 VSRedistInstalled
           Exec "$INSTDIR\vcredist_msvc2015_x86.exe /q"   ;若不存在,执行静默安装
   StrCpy $R0 "-1"
   ;MessageBox MB_OK  $R0

VSRedistInstalled:
   ;MessageBox MB_OK  "已安装"
   pop  $R0
 ; Delete "$INSTDIR\vcredist_msvc2015_x86."
FunctionEnd

7,补丁包  用于远程升级

; Script generated by the HM NIS Edit Script Wizard.

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "hiLive-path"
!define PRODUCT_VERSION "1.0.1"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\hilive.exe"

; MUI 1.67 compatible ------
!include "MUI.nsh"

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "patch.ico"

; Welcome page
!insertmacro MUI_PAGE_WELCOME
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "English"

; MUI end ------

Function .onInit
KillProcDLL::KillProc "hilive.exe" ;杀进程
Sleep 1000
FunctionEnd

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "hiLive-path-1.0.1.exe"
InstallDir "$PROGRAMFILES\hilive.exe"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show

SilentInstall silent ;静默安装
SilentUninstall silent ;静默安装
Section "MainSection" SEC01
  SetOutPath "$INSTDIR"
  SetOverwrite try
  File "path_1.0.1\hilive.exe"
SectionEnd

Section -Post
  WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\hilive.exe"
  WriteRegStr HKCU "Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" "$INSTDIR\hilive.exe" "RUNASADMIN" ;管理员运行
SectionEnd

Function .onInstSuccess
ExecShell "" "$INSTDIR\hilive.exe"
FunctionEnd

8,xp系统检测 并退出(需要装插件 https://blog.csdn.net/xt2zsun/article/details/79379098

#检测 Windows 7
var isWindowsXP
Section
Version::IsWindowsXP
 #获取值
 Pop $isWindowsXP
 ${if} $isWindowsXP == "1"
 MessageBox MB_OK "暂不支持XP系统,请升级到Win7及以上!"
 Quit
 ${EndIf}
SectionEnd 

9, 右键属性 详细信息

VIProductVersion "${PRODUCT_VERSION}" ;版本号,格式为 X.X.X.X (若使用则本条必须)
VIAddVersionKey  /LANG=2052 "ProductName" "我的程序" ;产品名称
VIAddVersionKey  /LANG=2052 "Comments" "这是我写的一个测试程序" ;备注
VIAddVersionKey  /LANG=2052 "CompanyName" "我的公司名称" ;公司名称
VIAddVersionKey  /LANG=2052 "LegalTrademarks" "Test Application is a trademark of Fake company" ;合法商标
VIAddVersionKey  /LANG=2052 "LegalCopyright" "Copyright (c) 2019 我的公司版权" ;合法版权
VIAddVersionKey  /LANG=2052 "FileDescription" "我的文件描述" ;文件描述(标准信息)
VIAddVersionKey  /LANG=2052 "FileVersion" "${PRODUCT_VERSION}" ;文件版本
VIAddVersionKey  /LANG=2052 "ProductVersion" "${PRODUCT_VERSION}" ;产品版本 

10,起始位置 相关

11,判断文件是否存在,用于检验插件是否安装

;存在执行 第三行,不存在执行第二行  不存在+1 行
IfFileExists "C:\Program Files (x86)\WinPcap\rpcapd.exe" +3 +2
MessageBox MB_OK  "已安装" ;占位 无实际作用
ExecWait '"$INSTDIR\WinPcap_4_1_3.exe" '

12,删除及创建快捷方式

Delete "$DESKTOP\快乐魔法狮.lnk"
SetOutPath "$INSTDIR"
CreateShortCut "$DESKTOP\快乐魔法狮.lnk" "$INSTDIR\hidteacher.exe"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

土拨鼠不是老鼠

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值