nsis接收命令行参数,实现动态安装

来源:互联网 发布:技术博客rss 知乎 编辑:程序博客网 时间:2024/06/05 11:43

功能:通过接收外部exe传入的参数,实现动态安装对应的安装包,以及动态设置安装路径

额外说明:外部传入的参数是通过命令行参数的方式传入的

作者:weekdawn

; Script generated by the HM NIS Edit Script Wizard.  var str4500var str4501var str4700var strProductName!include "logiclib.nsh"!include "FileFunc.nsh"Name "DC系列"OutFile "Setup.exe"SilentInstall silentAutoCloseWindow trueShowInstDetails nevershowSection "MainSection" SEC01  #通过命令行设置需要安装的产品名称和安装路径  push $R0  push $R1  push $R2  #获取命令行参数,形式:-product=“DC-4501” -path="D:\TEMP"  ${Getparameters} $R0  #解析参数数据  ${GetOptions} $R0 "-Product=" $R1  ${GetOptions} $R0 "-Path=" $R2  pop $R0  #设置安装路径  StrCpy $INSTDIR "$R2"  SetOutPath "$INSTDIR"  SetOverwrite ifnewer  File "D:\NsisPackage\公共文件.txt"    StrCpy $strProductName $R1  ${if} $R1 == $str4500  File /r  "D:\NsisPackage\DC-4500"  ${elseif} $R1 == $str4501  File /r "D:\NsisPackage\DC-4501"  ${elseif} $R1 == $str4700  File /r "D:\NsisPackage\DC-4700"  ${endif}  pop $R1  pop $R2SectionEndFunction .onInit  Call SetStringFunctionendFunction SetStringStrCpy  $str4500 "DC-4500"StrCpy  $str4501 "DC-4501"StrCpy  $str4700 "DC-4700"FunctionEnd


原创粉丝点击