标签:
此脚本支持打包mysql、安装mysql服务、安装windows服务、操作ini文件、操作注册表、高效压缩文件等功能,基本能满足常用的软件打包需求。
;定义各种常量 #define MyAppName "软件名称" #define MyAppDirName "软件目录名称" ;下面的版本号,公司名称,网址在 控制面板->卸载应用程序 的地方可看到 #define MyAppVersion "版本号" #define MyAppPublisher "公司名称" #define MyAppURL "软件网址链接" #define MyAppExeName "主执行文件.exe" [Setup] ; 注: AppId的值为单独标识该应用程序。 ; 不要为其他安装程序使用相同的AppId值。 ; (生成新的GUID,点击 工具|在IDE中生成GUID。) AppId={{1394783A-5D3C-48CD-8470-E2DFBB844E42} AppName={#MyAppName} AppVersion={#MyAppVersion} AppVerName={#MyAppName} AppPublisher={#MyAppPublisher} AppPublisherURL={#MyAppURL} AppSupportURL={#MyAppURL} AppUpdatesURL={#MyAppURL} DefaultDirName={pf}\{#MyAppDirName} DefaultGroupName={#MyAppName} ;安装包文件输出目录 OutputDir=D:\Output ;安装包文件名 OutputBaseFilename=setup ;压缩文件 Compression=lzma SolidCompression=yes ;以管理员权限运行 PrivilegesRequired=admin UninstallDisplayIcon={app}/{#MyAppExeName} VersionInfoVersion=1.0.0.0 ;安装包语言 [Languages] Name: "chinesesimp"; MessagesFile: "compiler:Default.isl" [Files] Source: "F:\Output\源程序文件目录\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs ;源程序文件目录 [Icons] Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" Name: "{userdesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; WorkingDir: "{app}"; ;安装完成后要执行的操作 [Run] Filename: "{app}\mysql\bin\mysqld"; Parameters: " --install mysql --defaults-file=""{app}\mysql\my.ini"""; WorkingDir: "{app}\mysql\bin"; Flags: runhidden; ;安装mysql服务 Filename: "{sys}\net"; Parameters: "start mysql"; WorkingDir: "{sys}"; Flags: runhidden; ;启动mysql服务 Filename: "{dotnet40}\installutil.exe"; Parameters: " MyService.exe"; WorkingDir: "{app}"; Flags: runhidden; ;安装windows服务 Filename: "{sys}\net"; Parameters: "start MyService"; WorkingDir: "{sys}"; Flags: runhidden; ;启动windows服务 Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, ‘&‘, ‘&&‘)}}"; Flags: nowait postinstall skipifsilent runasoriginaluser ;是否启动软件 ;卸载后执行的操作(停止、删除各种服务) [UninstallRun] Filename: "{sys}\net"; Parameters: "stop mysql"; WorkingDir: "{sys}"; Flags: runhidden; Filename: "{sys}\net"; Parameters: "stop MyService"; WorkingDir: "{sys}"; Flags: runhidden; Filename: "{app}\mysql\bin\mysqld"; Parameters: " --remove mysql"; WorkingDir: "{app}\mysql\bin"; Flags: runhidden; Filename: "{dotnet40}\installutil.exe"; Parameters: "/u MyService.exe"; WorkingDir: "{app}"; Flags: runhidden; ;操作my.ini文件,修改basedir和datadir目录 [INI] Filename: "{app}\mysql\my.ini"; Section: "mysqld"; Key: "basedir"; String: "{app}/mysql" Filename: "{app}\mysql\my.ini"; Section: "mysqld"; Key: "datadir"; String: "{app}/mysql/data" ;卸载后删除目录所有文件,删除空目录 [UninstallDelete] Type: filesandordirs; Name: "{app}\*" Type: dirifempty; Name: "{app}" ;操作注册表 [Registry] Root: HKLM; Subkey: "Software\SoftName"; Flags: uninsdeletekey;
标签:
原文地址:http://www.cnblogs.com/ccsharp/p/4961649.html