InnoSetup 脚本打包及管理员权限设置
InnoSetup使用教程:InnoSetup打包安装
脚本详细
1. 定义变量
#define MyAppName "TranslationTool"
#define MyAppChineseName "翻译工具"
#define MyAppVersion "1.0"
#define MyAppPublisher "dotnetschool"
#define MyAppURL "https://dotnet-campus.github.io/"
#define MyAppExeName "TranslationTool.exe"
2. 初始化安装包设置
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{AEDA7675-70DC-479E-B796-344517C2C954}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppChineseName}
OutputDir=C:\Users\\Desktop
OutputBaseFilename={#MyAppChineseName}
SetupIconFile=F:\GitHub\TranslationApiDemo\TranslationTool\TranslationTool\Images\bitbug_favicon.ico
Compression=lzma
SolidCompression=yes
其中,
- AppId 程序标识
- AppName 程序名称
- AppVersion 版本号。生成默认版本号AppName+AppVersion
- AppVerName 程序版本号。如果设置了AppVersion,则AppVerName会覆盖AppVersion值。
- AppPublisher 发布者
- AppPublisherURL、AppSupportURL、AppUpdatesURL 相关链接
- DefaultDirName 默认安装目录
- DefaultGroupName 默认开始菜单目录名
- OutputDir 打包exe的生成目录,比如可以设置在桌面
- OutputBaseFilename 打包exe的文件名称
- SetupIconFile 设置打包exe的图标
- Compression、SolidCompression 压缩相关
3. 启动文件和程序所有文件
[Files]
Source: "F:\GitHub\TranslationApiDemo\TranslationTool\TranslationTool\bin\Debug\TranslationTool.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "F:\GitHub\TranslationApiDemo\TranslationTool\TranslationTool\bin\Debug\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
忽略文件 Excludes: "*.bak,*.pdb,*.dll.config,*.ax,*\Log\*";
4. 图标
[Icons]
Name: "{group}\{#MyAppChineseName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppChineseName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppChineseName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
从上而下,分别是开始菜单中的启动快捷方式、开始菜单中的卸载快捷方式、桌面快捷方式
5. 直接启动
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#MyAppChineseName}}";Flags: nowait postinstall skipifsilent
在完成安装后,可以选择直接启动。
6. 添加Pascal代码
以上都只是innosetup提供的配置,如果需要定制注册表、卸载其它软件、定制界面、用户环境等,可以通过innosetup提供的一些事件来处理。如:
[code]
function InitializeSetup (): Boolean;
begin
MsgBox('程序安装!', mbInformation, MB_OK);
Result := true;
end;
此处只介绍一些常用的字段参数,详细的可参考其它博客:https://blog.csdn.net/yiyihuazi/article/details/60323746 、https://www.cnblogs.com/langtianya/p/4285570.html
案例脚本:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "TranslationTool"
#define MyAppChineseName "翻译工具"
#define MyAppVersion "1.0"
#define MyAppPublisher "dotnetschool"
#define MyAppURL "https://dotnet-campus.github.io/"
#define MyAppExeName "TranslationTool.exe" [Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{AEDA7675-70DC-479E-B796-344517C2C954}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppChineseName}
OutputDir=C:\Users\\Desktop
OutputBaseFilename={#MyAppChineseName}
SetupIconFile=F:\GitHub\TranslationApiDemo\TranslationTool\TranslationTool\Images\bitbug_favicon.ico
Compression=lzma
SolidCompression=yes [Languages]
Name: "english"; MessagesFile: "compiler:Default.isl" [Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked [Files]
Source: "F:\GitHub\TranslationApiDemo\TranslationTool\TranslationTool\bin\Debug\TranslationTool.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "F:\GitHub\TranslationApiDemo\TranslationTool\TranslationTool\bin\Debug\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files [Icons]
Name: "{group}\{#MyAppChineseName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppChineseName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppChineseName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon [Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#MyAppChineseName}}";Flags: nowait postinstall skipifsilent
设置安装包以管理员权限运行
如果安装包需要以管理员运行,在VS中设置程序以管理员权限启动之后,
在InnoSetup安装目录下,找到配置SetupLdr.e32文件,设置Manifest中的权限启动参数(与VisualStudio类似),操作如下:
下载Resource Hacker编译器,然后打开.e32文件,将其中权限相关参数,修改为管理员权限。

详细操作可参考:用inno setup制作管理员权限启动的安装包
案例截图
生成的安装包exe以及安装后桌面快捷方式

开始菜单中的快捷方式

InnoSetup 脚本打包及管理员权限设置的更多相关文章
- EasyNVR摄像机H5流媒体服务器在windows上批处理脚本自动以管理员权限运行
很多时候, 我们需要以管理员权限来运行批处理脚本, 比如操作 windows 服务. EasyNVR 中提供安装服务的批处理脚本, 运行这个bat文件, 自动将 EasyNVR 以 windows 服 ...
- sharepoint 脚本 强迫以管理员权限运行
#region 关键代码:强迫以管理员权限运行 $currentWi = [Security.Principal.WindowsIdentity]::GetCurrent() $currentWp = ...
- 使用applescript脚本方式以管理员权限运行
- (BOOL) runProcessAsAdministrator:(NSString*)scriptPath withArguments:(NSArray ...
- 修改hosts文件(判断是否为管理员/以管理员权限运行脚本)
将以下命令保存为 HostsModify.ps1,然后执行即可 #该脚本用来添加hosts解析记录.脚本在执行的时候会判断当前用户是否为管理员,如果不是则弹出提示框口,要求输入相应密码 If (-NO ...
- wiki----为用户设置管理员权限
wiki页面的管理员权限设置方法: wiki的页面好像没办法修改,只能在数据库中进行操作: 1.进入到wiki的安装目录下: #cd /var/www/html/wiki 2.查看wiki的配置文件, ...
- 你需要管理员权限才能删除文件夹及服务器C盘不及批处理
Windows 7系统,管理员权限设置方法 一.选择文件夹或文件所有者 我们用鼠标右键点击要操作的文件或文件夹 - 属性: 在出现的文件夹属性窗口,我们用鼠标左键点击:安全: 我们用鼠标左键点击:高级 ...
- Inno Setup打包的程序提升为管理员权限
Inno Setup打包的程序在Win7 64位系统上安装,安装步骤最后一步若选中运行程序,会跳出一个错误提示框. 这是因为64位win7系统运行程序时需要管理员权限,而打包的文件并没有这个权限就试图 ...
- Inno Setup打包添加和去除管理员权限
原文:Inno Setup打包添加和去除管理员权限 添加管理员权限 1.在[Setup]节点添加 PrivilegesRequired=admin 2.进入安装目录,找到文件SetupLdr.e32, ...
- 【程序打包工具 Inno Setup】CreateProcess 失败:代码 740(Inno Setup打包的程序提升为管理员权限)
原文参考 https://www.cnblogs.com/SnailProgramer/p/4243666.html http://blog.csdn.net/x356982611/article/d ...
随机推荐
- 卸载office密钥的命令
1,管理员运行CMD或者PowerShell2,转到2016安装目录,C:\Program Files\Microsoft Office\Office16,这是64位的,32位的在C:\Program ...
- Postman-----如何导入和导出
此处介绍2种导出和导入的操作方法,一种是通过分享link,另一种是导出json文件,再次导入,个人推荐link的方式,简单方便,下面将详细介绍. 第一种:分享链接,导入链接的方式 1.1.生成link ...
- MYSQL—— year类型的使用与注意点!
mysql的日期与时间类型:分为time.date.datetime.timestamp.year,主要总结下year的用法: 1.类型支持:year 与 year(4),注意无year(2)的定义方 ...
- 将wiki人脸数据集的性别信息提取出来制作标签
import scipy.io as scio dataFile = 'D:\\Users\\a\\Documents\\Tencent Files\\178026882\\FileRecv\\wik ...
- 怎么动态生成js变量
动态生成全局变量: //简单的用字符串作为变量名 window['hello'] = "hello, world"; alert(hello); //批量定义 for(var ...
- vue.js框架原理浅析
vue.js是一个非常优秀的前端开发框架,不是我说的,大家都知道. 首先我现在的能力,独立阅读源码还是有很大压力的,所幸vue写的很规范,通过方法名基本可以略知一二,里面的原理不懂的地方多方面查找资料 ...
- TensorFlow从1到2(一)续讲从锅炉工到AI专家
引言 原来引用过一个段子,这里还要再引用一次.是关于苹果的.大意是,苹果发布了新的开发语言Swift,有非常多优秀的特征,于是很多时髦的程序员入坑学习.不料,经过一段头脑体操一般的勤学苦练,发现使用S ...
- 【由浅至深】redis 实现发布订阅的几种方式
非常感谢依乐祝发表文章<.NET Core开发者的福音之玩转Redis的又一傻瓜式神器推荐>,对csredis作了一次完整的诠释. 前言 提到消息队列,最熟悉无疑是 rabbitmq,它基 ...
- COW奶牛!Copy On Write机制了解一下
前言 只有光头才能变强 在读<Redis设计与实现>关于哈希表扩容的时候,发现这么一段话: 执行BGSAVE命令或者BGREWRITEAOF命令的过程中,Redis需要创建当前服务器进程的 ...
- SpringBoot整合SpringCloud搭建分布式应用
什么是SpringCloud? SpringCloud是一个分布式的整体解决方案.SpringCloud为开发者提供了在分布式系统中快速构建的工具,使用SpringCloud可以快速的启动服务或构建应 ...