使用NSIS (NullSoft Scriptable Install System)制作安装程序

该博客介绍了如何使用NullSoft Scriptable Install System (NSIS)来制作安装程序。内容包括设置输出文件名、安装目录,创建快捷方式,以及添加卸载功能。还详细讲解了DownloadImage函数,用于从远程地址下载文件并保存到本地安装目录。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Name "capture"
OutFile "capture.exe"
InstallDir "$PROGRAMFILES\capture"
Page directory
Page INSTFILES
UninstPage uninstConfirm
UninstPage instfiles
Var remote_zip_file
Var local_zip_file
Section ""
SetOutPath $INSTDIR
;Call DownloadVM
Call DownLoadImage
/*增加快捷方式到桌面和windows菜单*/
CreateDirectory "$SMPROGRAMS\capture\capture.exe"
CreateShortCut "$SMPROGRAMS\capture\capture.lnk" $INSTDIR\capture.exe
CreateShortCut "$DESKTOP\截图工具.lnk" $INSTDIR\capture.exe
Exec "$INSTDIR\capture.exe"
SetAutoClose true




/*增加卸载相关的模块*************************************
Section "Uninstall"
Delete "$INSTDIR\*.exe"
RMDir "$INSTDIR"
#快捷方式的删除
Delete "$SMPROGRAMS\capture\capture.lnk"
Delete "$DESKTOP\capture.lnk"
Delete "$SMPROGRAMS\capture\uninstall.lnk"
Sectionend
*/




/***************提供有uninstall.exe******************************************/
#CreateShortCut "$SMPROGRAMS\capture\uninstall.exe "$INSTDIR\uninstall.lnk"
#WriteUninstaller "$INSTDIR\uninstall.exe"
SectionEnd
;下载虚拟机


;下载映像
Function DownloadImage
StrCpy $remote_zip_file "http://lx.cdn.baidupcs.com/file/891b5d0cbcb36bfdfe1cf78e1b9a8606?bkt=p-f90fc2fcdb6bd141f37ee85d5dff6ef4&xcode=df2721f30e8b40d859c28ca7a3cf771bfef5f5d35a1b8d3d837047dfb5e85c39&fid=1277056680-250528-223982309163508&time=1415073762&sign=FDTAXERB-DCb740ccc5511e5e8fedcff06b081203-BWh3U6%2BrJc7Jq%2FfqafcdbWT%2FwGI%3D&to=sc&fm=Bei,B,U,nc&sta_dx=1&sta_cs=17&sta_ft=exe&sta_ct=6&newver=1&newfm=1&flow_ver=3&expires=8h&rt=pr&r=488712453&mlogid=1177857759&vuk=1277056680&vbdid=425043010&ifn=capture.exe&fn=capture.exe"
StrCpy $local_zip_file "capture.exe"
Call DownloadFile
FunctionEnd
/*************************************************/
#函数名:DownloadFile
#参数:remote_zip_file 文件下载地址,local_zip_file 下载到本地的相对路径名
#返回值:无
#描述:将网络文件下载到指定的本地目录进行安装
/************************************************/
Function DownloadFile
NSISdl::download $remote_zip_file "$INSTDIR\$local_zip_file"
Pop $R0
StrCmp $R0 "success" download_ok
SetDetailsView show
DetailPrint "download failed:$R0"
Abort
download_ok:
DetailPrint "downdload $R0 ok"
FunctionEnd





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值