【模板下载】innosetup 制作.net安装包的模板
这个模板是在博客园和CodeProject上的代码修改而成的,感谢原作者
模板是2个
innosetup 制作.net 2.0 安装包的模板
innosetup 制作.net 4.0 安装包的模板
innosetup 制作.net 2.0 安装包的模板 代码如下:
; 脚本由 Inno Setup 脚本向导 生成!
; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!
#define MyAppName "应用程序名称"
#define MyAppVersion "1.0.0"
#define MyAppPublisher " "
#define MyAppURL "www.qq.com"
#define MyAppExeName "MyApp.exe"
#define IncludeFramework true
#define IsExternal ""
#define IsAdminLoggedOn true
;放置客户端文件的地方
#define SourceFileDir "D:\ClientApp\"
[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID,点击 工具|在IDE中生成GUID。)
AppId={{D4CA6231-73B5-4FD9-99E9-2568C4C5A0D1}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
;如果用户选择的文件夹已经存在,是否提示
DirExistsWarning=no
;卸载程序所在的文件夹,将会与我们的程序存在于同一文件夹中
UninstallFilesDir={app}
;卸载程序所使用的图标 在添加删除程序中
UninstallDisplayIcon={app}\{#MyAppName}
Compression=lzma
SolidCompression=yes
#if IncludeFramework
OutputBaseFilename=setup_FW
#else
OutputBaseFilename=Setup
#endif
;输出目录
OutputDir={#SourceFileDir}\setup
;是否在程序组中允许卸载
Uninstallable=yes
UninstallDisplayName=卸载{#MyAppName}
[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone;
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
;Source: "{#SourceFileDir}\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion {#IsExternal}
;创建子文件夹的示例
;Source: "{#SourceFileDir}\a\mbs485.exe"; DestDir: "{app}\a"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "D:\ClientApp\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
#if IncludeFramework
;net Framework2.0放在另一个文件夹中
Source: "D:\DotnetFolder\dotnetfx.exe"; DestDir: "{tmp}"; Flags: ignoreversion {#IsExternal}; Check: NeedsFramework
#endif
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" ;WorkingDir: "{app}"
;桌面快捷方式
;ico2.ico是在桌面显示快捷方式的图标
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon ;WorkingDir:"{app}"; IconFilename: "{app}\ico2.ico";
; 快速启动
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon ;WorkingDir: "{app}"
;卸载
Name: "{group}\卸载{#MyAppName}"; Filename: "{uninstallexe}"
[Registry]
;注册表中添加自启动
Root: HKLM; Subkey: "software\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "MyStartKey"; ValueData: "{app}\{#MyAppExeName} /s"; Flags: uninsdeletevalue
[Run]
#if IncludeFramework
;加入 /passive 看看是否能单独安装此.net 框架
Filename: {tmp}\dotnetfx.exe; Parameters: "/q:a /c:""install /l /q"""; WorkingDir: {tmp}; Flags: skipifdoesntexist; StatusMsg: "正在安装程序运行所必须的.NET Framework2.0框架,大概需要2-5分钟,请稍后"
#endif
Filename: {win}\Microsoft.NET\Framework\v2.0.50727\CasPol.exe; Parameters: "-q -machine -remgroup ""{#MyAppName}"""; WorkingDir: {tmp}; Flags: skipifdoesntexist runhidden; StatusMsg: "设置程序访问权限..."
Filename: {win}\Microsoft.NET\Framework\v2.0.50727\CasPol.exe; Parameters: "-q -machine -addgroup 1.2 -url ""file://{app}/*"" FullTrust -name ""{#MyAppName}"""; WorkingDir: {tmp}; Flags: skipifdoesntexist runhidden; StatusMsg: "设置程序访问权限..."
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
[UninstallRun]
Filename: {win}\Microsoft.NET\Framework\v2.0.50727\CasPol.exe; Parameters: "-q -machine -remgroup ""MyAppName"""; Flags: skipifdoesntexist runhidden;
[code]
// Indicates whether .NET Framework 2.0 is installed.
function IsDotNET20Detected(): boolean;
var
success: boolean;
install: cardinal;
begin
success := RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727', 'Install', install);
Result := success and (install = );
end;
//RETURNS OPPOSITE OF IsDotNet20Detected FUNCTION
//Remember this method from the Files section above
function NeedsFramework(): Boolean;
begin
Result := (IsDotNET20Detected = false);
end;
//CHECKS TO SEE IF CLIENT MACHINE IS WINDOWS 95
function IsWin95 : boolean;
begin
Result := (InstallOnThisVersion('4.0,0', '4.1.1998,0') = irInstall);
end;
//CHECKS TO SEE IF CLIENT MACHINE IS WINDOWS NT4
function IsWinNT : boolean;
begin
Result := (InstallOnThisVersion('0,4.0.1381', '0,4.0.1381') = irInstall);
end;
//GETS VERSION OF IE INSTALLED ON CLIENT MACHINE
function GetIEVersion : String;
var
IE_VER: String;
begin
{First check if Internet Explorer is installed}
if RegQueryStringValue(HKLM,'SOFTWARE\Microsoft\Internet Explorer','Version',IE_VER) then
Result := IE_VER
else
{No Internet Explorer at all}
result := '';
end;
//GETS THE VERSION OF WINDOWS INSTALLER DLL
function GetMSIVersion(): String;
begin
GetVersionNumbersString(GetSystemDir+'\msi.dll', Result);
end;
//LAUNCH DEFAULT BROWSER TO WINDOWS UPDATE WEBSITE
procedure GoToWindowsUpdate;
var
ErrorCode: Integer;
begin
) + chr() + '(Requires Internet Connection)'
, mbConfirmation, MB_YESNO) = IDYES) then
ShellExec('open', 'http://windowsupdate.microsoft.com','', '', SW_SHOW, ewNoWait, ErrorCode);
end;
//IF SETUP FINISHES WITH EXIT CODE OF 0, MEANING ALL WENT WELL
//THEN CHECK FOR THE PRESENCE OF THE REGISTRY FLAG TO INDICATE THE
//.NET FRAMEWORK WAS INSTALLED CORRECTLY
//IT CAN FAIL WHEN CUST DOESN'T HAVE CORRECT WINDOWS INSTALLER VERSION
function GetCustomSetupExitCode(): Integer;
begin
if (IsDotNET20Detected = false) then
begin
MsgBox('.NET Framework没有安装成功!',mbError, MB_OK);
result := -
end
end;
//启动的时候进行系统检查,检查系统环境是否符合安装
function InitializeSetup: Boolean;
var
Version: TWindowsVersion;
IE_VER: String;
MSI_VER: String;
NL: Char;
NL2: String;
// ResultCode: integer; 用于在安装程序运行前执行某个程序
begin
// if Exec(ExpandConstant('{win}\notepad.exe'), '', '', SW_SHOW,
// ewWaitUntilTerminated, ResultCode) then
NL := Chr();
NL2 := NL + NL;
// Get Version of Windows from API Call
GetWindowsVersionEx(Version);
// On Windows 2000, check for SP3
if Version.NTPlatform and
(Version.Major = ) and
(Version.Minor = ) and
(Version.ServicePackMajor < ) then
begin
SuppressibleMsgBox('Win2000系统需要安装sp3补丁包.' + NL +
'访问' + NL2 +
' *** http://windowsupdate.microsoft.com ***' + NL2 +
'来获取补丁包,' + NL +
'并安装',
mbCriticalError, MB_OK, MB_OK);
GoToWindowsUpdate;
Result := False;
Exit;
end;
// On Windows XP, check for SP2
if Version.NTPlatform and
(Version.Major = ) and
(Version.Minor = ) and
(Version.ServicePackMajor < ) then
begin
SuppressibleMsgBox('Winxp系统至少需要安装sp2补丁包' + NL +
'访问' + NL2 + ' *** http://windowsupdate.microsoft.com ***' + NL2 +
'来获取补丁包,' + NL +
'并安装',
mbCriticalError, MB_OK, MB_OK);
GoToWindowsUpdate;
Result := False;
Exit;
end;
//IF WINDOWS 95 OR NT DON'T INSTALL
if (IsWin95) or (IsWinNT) then
begin
SuppressibleMsgBox('本程序不能运行在win95或 Windows NT系统上.',
mbCriticalError, MB_OK, MB_OK);
Result := False;
Exit;
end;
//CHECK MSI VER, NEEDS TO BE 3.0 ON ALL SUPPORTED SYSTEM EXCEPT 95/ME, WHICH NEEDS 2.0)
MSI_VER := GetMSIVersion
')) then
begin
SuppressibleMsgBox('您的windows系统需要更新.' + NL +
'访问*** http://windowsupdate.microsoft.com *** 来获取更新,' + NL +
'and then reinstall this program',
mbCriticalError, MB_OK, MB_OK);
GoToWindowsUpdate;
Result := False;
Exit;
end;
//CHECK THE IE VERSION (NEEDS TO BE 5.01+)
IE_VER := GetIEVersion;
if IE_VER < '5.01' then
begin
if IE_VER = '' then
begin
MsgBox('需要IE为5.0或以上版本.' + NL2 +
'您没有安装IE浏览器或者浏览器损坏' + NL +
'请升级您的浏览器程序', mbInformation, MB_OK);
end
else
begin
MsgBox('需要IE为5.0或以上版本.' + NL2 +
'您的IE版本为 ' + IE_VER + '.' + NL2 +
'请升级您的浏览器程序.', mbInformation, MB_OK);
end
GoToWindowsUpdate;
result := false;
exit;
end;
//MAKE SURE USER HAS ADMIN RIGHTS BEFORE INSTALLING
if IsAdminLoggedOn then
begin
result := true
exit;
end
else
begin
MsgBox('您必须拥有管理员权限来执行此次操作.' + NL +
'请使用管理员账户登录,' + NL +
'然后重新运行此程序.', mbInformation, MB_OK);
result := false;
end
end;
end.
innosetup 制作.net 4.0 安装包的模板 代码如下:
; 脚本由 Inno Setup 脚本向导 生成!
; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!
#define MyAppName "应用程序"
#define MyAppVersion "1.0.0"
#define MyAppPublisher " "
#define MyAppURL "www.qq.com"
#define MyAppExeName "AppClient.exe"
#define IncludeFramework true
#define IsExternal ""
#define IsAdminLoggedOn true
;ClientApp是客户端程序所在的文件夹
#define SourceFileDir "D:\ClientApp\"
[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID,点击 工具|在IDE中生成GUID。)
AppId={{D74B494C-8E8D-46BD-B166-142678A51AF2}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
;如果用户选择的文件夹已经存在,是否提示
DirExistsWarning=no
;卸载程序所在的文件夹,将会与我们的程序存在于同一文件夹中
UninstallFilesDir={app}
;卸载程序所使用的图标 在添加删除程序中
UninstallDisplayIcon={app}\{#MyAppName}
Compression=lzma
SolidCompression=yes
#if IncludeFramework
OutputBaseFilename=setup_FW
#else
OutputBaseFilename=Setup
#endif
;输出目录
OutputDir={#SourceFileDir}\setup
;是否在程序组中允许卸载
Uninstallable=yes
UninstallDisplayName=卸载{#MyAppName}
[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone;
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "D:\ClientV4\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
#if IncludeFramework
;把.net framework .0放在另一个文件件中
Source: "D:\NetFramework4\dotNetFx40_Full_x86_x64.exe"; DestDir: "{tmp}"; Flags: ignoreversion {#IsExternal}; Check: NeedsFramework
#endif
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" ;WorkingDir: "{app}"
;桌面快捷方式
;ico2.ico是要在桌面显示的快捷方式的ico
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon ;WorkingDir:"{app}"; IconFilename: "{app}\ico2.ico";
;快速启动
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon ;WorkingDir: "{app}"
;卸载
Name: "{group}\卸载{#MyAppName}"; Filename: "{uninstallexe}"
;注册开机启动 暂时不启用
;[Registry]
;注册表中添加自启动
;Root: HKLM; Subkey: "software\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "MyStartKey"; ValueData: "{app}\{#MyAppExeName} /s"; Flags: uninsdeletevalue
[Run]
#if IncludeFramework
Filename: {tmp}\dotNetFx40_Full_x86_x64.exe; Parameters: "/q:a /c:""install /l /q"""; WorkingDir: {tmp}; Flags: skipifdoesntexist; StatusMsg: "正在安装程序运行所必须的.NET Framework4.0框架,大概需要2-5分钟,请稍后"
#endif
Filename: {win}\Microsoft.NET\Framework\v4.0.30319\CasPol.exe; Parameters: "-q -machine -remgroup ""{#MyAppName}"""; WorkingDir: {tmp}; Flags: skipifdoesntexist runhidden; StatusMsg: "设置程序访问权限..."
Filename: {win}\Microsoft.NET\Framework\v4.0.30319\CasPol.exe; Parameters: "-q -machine -addgroup 1.2 -url ""file://{app}/*"" FullTrust -name ""{#MyAppName}"""; WorkingDir: {tmp}; Flags: skipifdoesntexist runhidden; StatusMsg: "设置程序访问权限..."
[UninstallRun]
Filename: {win}\Microsoft.NET\Framework\v4.0.30319\CasPol.exe; Parameters: "-q -machine -remgroup ""{#MyAppName}"""; Flags: skipifdoesntexist runhidden;
[code]
// Indicates whether .NET Framework 4.0 is installed.
function IsDotNET40Detected(): boolean;
var
success: boolean;
install: cardinal;
begin
success := RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full', 'Install', install);
Result := success and (install = );
end;
//RETURNS OPPOSITE OF IsDotNet20Detected FUNCTION
//Remember this method from the Files section above
function NeedsFramework(): Boolean;
begin
Result := (IsDotNET40Detected = false);
end;
function GetCustomSetupExitCode(): Integer;
begin
if (IsDotNET40Detected = false) then
begin
MsgBox('.NET Framework 未能正确安装!',mbError, MB_OK);
result := -
end
end;
//卸载程序
function InitializeUninstall(): Boolean;
begin
Result := MsgBox(# '你真的要卸载该程序?', mbConfirmation, MB_YESNO) = idYes;
//if Result = False then
// MsgBox('InitializeUninstall:' #13#13 'Ok, bye bye.', mbInformation, MB_OK);
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
ErrorCode: Integer;
begin
case CurUninstallStep of
usUninstall:
begin
//MsgBox('卸载程序:' #13#13 '正在卸载...', mbInformation, MB_OK)
// ...insert code to perform pre-uninstall tasks here...
end;
usPostUninstall:
begin
//MsgBox('卸载程序:' #13#13 '卸载完成.', mbInformation, MB_OK);
// ...insert code to perform post-uninstall tasks here...
ShellExec('open', 'http://www.qq.cn', '', '', SW_SHOW, ewNoWait, ErrorCode)
end;
end;
end;
【模板下载】innosetup 制作.net安装包的模板的更多相关文章
- 使用WinRar软件制作程序安装包
之前我写过使用好压软件打包程序,见随笔: 使用好压(HaoZip)软件打包EverEdit制作安装程序 - Fetty - 博客园http://www.cnblogs.com/fetty/p/4907 ...
- 7z制作自解压安装包
像7z和winRAR这样的压缩工具都支持制作自解压的文件.所谓自解压的文件就是不需要目标机器上安装解压工具,通过运行压缩包自己即可解压出压缩包中的文件.下面我们就介绍一下如何利用7z的自解压功能制作应 ...
- 制作部署安装包:Inno Setup
制作部署安装包:Inno Setup 前一篇尝试Office 2003 VSTO的开发.部署有提到用VS开发一个简单的VSTO程序.打包C/S程序,我首先想到的是VS里自带的Setup Project ...
- C#进阶系列——使用Advanced Installer制作IIS安装包(二:配置安装包依赖项和自定义dll)
前言:上篇C#进阶系列——使用Advanced Installer制作IIS安装包(一:配置IIS和Web.config)介绍了下使用Advanced Installer配置IIS和Web.confi ...
- DevExpress控件库 开发使用经验总结3 制作项目安装包
2015-01-27 使用DevExpress控件包开发C/S项目完成后,部署前需要制作本地安装包.本文还是使用“SetupFactory”安装工厂来制作安装包.在以前的系列文章中详细介绍过该工具的使 ...
- 使用Advanced Installer制作IIS安装包(二:配置安装包依赖项和自定义dll)
前言:上篇使用Advanced Installer制作IIS安装包(一:配置IIS和Web.config)介绍了下使用Advanced Installer配置IIS和Web.config的过程,操作起 ...
- Mac如何找到从AppStore下载的正版Xcode安装包
前言:本文介绍在Mac下如何找到AppStore下载的安装包路径,以及如何提取出来供以后使用,希望对大家有所帮助(前提:想要提取某个安装包,前提是你正在从AppStore安装这个程序.比如你想提取im ...
- 省去在线安装 直接下载Chrome官方离线安装包
首页>软件之家>便捷上网 省去在线安装 直接下载Chrome官方离线安装包 2013-10-12 23:22:02来源:IT之家 原创作者:阿象责编:阿象人气:54487 评论:19 谷歌 ...
- installshield制作的安装包卸载时提示重启动的原因以及解决办法
原文:installshield制作的安装包卸载时提示重启动的原因以及解决办法 有时候卸载installshield制作的安装包程序,卸载完会提示是否重启电脑以完成所有卸载,产生这个提示的常见原因有如 ...
随机推荐
- [转] Android获取Manifest中<meta-data>元素的值
转自: http://www.2cto.com/kf/201303/194824.html android 开发中: 在AndroidManifest.xml中,<meta-data> ...
- 战胜C语言中令人头疼的问题
C语言一共32个关键字,下面一一列出: 1.auto声明自动变量 在默认情况下,编译器默认所有变量都是auto 2.int声明整型变量 3.double声明双精度变量 4.long声明长整型变量 ...
- thinkphp模板调用函数用法
注意:自定义函数要放在项目应用目录/common/common.php中. 这里是关键. 模板变量的函数调用格式为: {$varname|function1|function2=arg1,arg2,# ...
- 动态替换fragment
// [1]获取手机的宽和高 windommanager WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE); in ...
- 【Linux系统】防暴力破解
在日志文件/var/log/secure 中可以看到涉及到安全方面的日志,可以查看是否有人尝试暴力破解及是否成功,对于肉鸡行为有一定帮助 思路基本上都是加强密码的复杂度,增加iptables配置黑名单 ...
- python 打包与部署
环境:win10.eclipse-jee-mars.python2.7 打包在linux上进行安装测试 1.1 打包 项目目录结构如下: 打包对象:utils.reg 在P1项目的顶级目录,也就是ut ...
- 选择排序算法Java与Python实现
Java 实现 package common; public class SimpleArithmetic { /** * 选择排序 * 输入整形数组:a[n] [4.5.3.7] * 1. 取数组编 ...
- MapReduce中作业调度机制
MapReduce中作业调度机制主要有3种: 1.先入先出FIFO Hadoop 中默认的调度器,它先按照作业的优先级高低,再按照到达时间的先后选择被执行的作业. 2.公平调度器(相当于时间 ...
- Eclipse启动tomcat时报错:Multiple Contexts have a path of "/xxx"
今天使用Eclipse启动tomcat部署项目时,遇到一个奇怪的错误: Could not publish server configuration for Tomcat v6.0 Server at ...
- 20160808_Shell书
1. http://item.jd.com/11075150.html 2.