原文 用Inno Setup制作WEB程序安装包

最近做了一个WEB程序的安装包,我把制作的过程做个介绍,贴出源码给大家做个参考

看看inno 的脚本

[Setup]
AppCopyright=test
AppName=test
AppVerName=test v2.0
SolidCompression=true
OutputDir=Output\
OutputBaseFilename=test_setup
DefaultDirName={pf}\Lms
DefaultGroupName=Lms
;安装程序的基本信息
[_ISTool]
UseAbsolutePaths=false [UninstallDelete]
Type: files; Name: {app}\init_test.log
Type: dirifempty; Name: {app}\database
;需要提示卸载程序额外删除的目录
[Run]
Filename: {tmp}\SetACL.EXE; Parameters: "-ot file -on ""{app}"" -actn ace -ace ""n:S-1-5-20;s:y;p:change,full"""; Flags: runhidden waituntilterminated skipifdoesntexist
Filename: {tmp}\SetACL.EXE; Parameters: "-ot file -on ""{app}"" -actn ace -ace ""n:S-1-5-32-545;s:y;p:change,full"""; Flags: runhidden waituntilterminated skipifdoesntexist
Filename: {tmp}\SetACL.EXE; Parameters: "-ot file -on ""{app}"" -actn ace -ace ""n:S-1-1-0;s:y;p:change,full"""; Flags: runhidden waituntilterminated skipifdoesntexist
Filename: {tmp}\SetACL.EXE; Parameters: "-ot file -on ""{app}\database"" -actn ace -ace ""n:S-1-1-0;s:y;p:change,full"""; Flags: runhidden waituntilterminated skipifdoesntexist
Filename: {tmp}\init_test.exe; Parameters: """{app}"" 2.0"; Description: Configure SQLServer; StatusMsg: Configuring Database; Flags: postinstall skipifdoesntexist
;uncomment this line to use for dotnet 1.1
;Filename: {tmp}\SetACL.exe; Parameters: "-ot file -on ""{win}\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files"" -actn ace -ace ""n:S-1-1-0;s:y;p:change,full"""; Flags: runhidden
Filename: {tmp}\SetACL.exe; Parameters: "-ot file -on ""{win}\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files"" -actn ace -ace ""n:S-1-1-0;s:y;p:change,full"""; Flags: runhidden
;安装过程需要运行的程序,SetACL.EXE是一个第三方组件使用方法大家可以google一下,init_test.exe为附加数据库和数据还有设置asp.net版本的程序 [Dirs]
Name: {app}\database
Name: {app}\course
;产生目录
[Types]
Name: Custom; Description: Custom installation; Flags: iscustom [Files]
Source: 3rdParty\SetACL.exe; DestDir: {tmp}; flags: deleteafterinstall
Source: test\*; DestDir: {app}; Excludes:*.webinfo,*.vspscc, \obj,Thumbs.db,CVS,*.pdb,*.cs,*.scc,*.bak,*.csproj,*.log,*.Old,*.user,*.lic,*.sln,*.suo,8.rar; Flags: recursesubdirs
Source: test_table.sql; DestDir: {tmp}; Flags: deleteafterinstall
Source: test_Data.sql; DestDir: {tmp}; Flags: deleteafterinstall
Source: init_test.exe; DestDir: {tmp}; flags: deleteafterinstall
;需要随安装包一起打包的文件
[Code]
const
VDirName = 'test';
Vwebctrl = 'webctrl_client';
IISServerNumber = '1'; function SafeCreateOleObject(ProgId:String;ExceptionMsg:String):Variant;
var
retobj:Variant;
begin
try
retobj := CreateOleObject(ProgId);
except
RaiseException(ExceptionMsg+''#13#13'(Error ''' + GetExceptionMessage + ''' occurred)');
end;
Result:=retobj;
end; {
create virtual directory, pointing to installation directory
} procedure SetupIIS;
var
IIS, WebSite, WebServer, WebRoot, VDir: Variant;
begin
{ Create the main IIS COM Automation object }
IIS:=SafeCreateOleObject('IISNamespace','Please install Microsoft IIS first.');
{ Connect to the IIS server } WebSite := IIS.GetObject('IIsWebService', GetComputerNameString() + '/w3svc');
WebServer := WebSite.GetObject('IIsWebServer', IISServerNumber);
WebRoot := WebServer.GetObject('IIsWebVirtualDir', 'Root'); { (Re)create a virtual dir } try
WebRoot.Delete('IIsWebVirtualDir', VDirName);
except
end;
try
WebRoot.Delete('IIsWebVirtualDir', Vwebctrl);
except
end; If DirExists(ExpandConstant('{app}')) then
begin
VDir := WebRoot.Create('IIsWebVirtualDir', VDirName);
VDir.AccessRead := True;
VDir.AccessFlags:=529;
VDir.AppFriendlyName := 'LMS Website';
VDir.Path := ExpandConstant('{app}\');
VDir.EnableDirBrowsing:=False;
VDir.EnableDefaultDoc:=True;
VDir.DefaultDoc :='Default.aspx';
VDir.AppCreate(True);
VDir.SetInfo();
end; If DirExists(ExpandConstant('{app}\IEWebControl\'+Vwebctrl)) then
begin
VDir := WebRoot.Create('IIsWebVirtualDir', Vwebctrl);
VDir.AccessRead := True;
VDir.AccessFlags:=529;
VDir.AppFriendlyName := 'visual web ctral';
VDir.Path := ExpandConstant('{app}\IEWebControl\'+Vwebctrl);
VDir.EnableDirBrowsing:=False;
VDir.EnableDefaultDoc:=True;
VDir.DefaultDoc :='default.htm';
VDir.AppCreate(True);
VDir.SetInfo();
end;
end;
procedure ControlIIS(bState:boolean);
var
resultcode:integer;
param:string;
begin
if bState then
param:='START'
else param:='STOP'; Exec('NET.EXE',param+' "IIS ADMIN"',
ExpandConstant('{sys}'),SW_SHOW,ewWaitUntilTerminated,resultcode
);
end;
;在IIS默认站点下添加虚拟目录
procedure CurStepChanged(CurStep: TSetupStep);
begin
case CurStep of
ssPostInstall:
begin
SetupIIS();
//ControlIIS(true);
end;
ssInstall:
//ControlIIS(false);
else
;
end;
end;

  

再来看一下init_lms.exe的主要方法:

 private void CreateDatabase()
{
string sql = " CREATE DATABASE "
+ dbName; if (IsLocalInstall())
{
sql += " ON PRIMARY (NAME = " + dbDataName + ", "
+ " FILENAME = '" + getDir("database\\" + dbDataName + ".mdf") + "', "
+ " SIZE = 5MB,"
+ " FILEGROWTH =1) "
+ " LOG ON (NAME =" + dbLogName + ", "
+ " FILENAME = '" + getDir("database\\" + dbLogName + ".ldf") + "', "
+ " SIZE = 1MB, "
+ " FILEGROWTH =1) ";
}
sql += " COLLATE Chinese_PRC_CI_AS";
try
{
this.Cursor = Cursors.WaitCursor;
frmProg.StepText("drop database");
if (chkCreateDB.Checked)
{
try
{
execSQL("master", "DROP DATABASE " + dbName);
writeLog("old database dropped");
}
catch (Exception)
{
writeLog("database not found or unable to be dropped");
} }
frmProg.StepText("creating database");
if (chkCreateDB.Checked)
{
try
{
execSQL("master", sql);
writeLog("DB CREATED:" + sql);
}
catch (Exception e)
{
writeLog("DB CREATING ERROR:" + e.Message);
}
} frmProg.StepText("creating tables"); if (chkTables.Checked)
{
writeLog("exec lmsdb_table.sql");
dmoExecSQL(sqlb_t.ToString());//dbName, sqlb);
} frmProg.StepText("initialize base data"); if (chkDatas.Checked)
{
//writeLog(sqlb.ToString());
writeLog("exec lmsbasedata.sql");
dmoExecSQL(sqlb_d.ToString());//execSQL(dbName, sqlb);
}
frmProg.StepText("database initialization is done");
}
finally
{
this.Cursor = Cursors.Default;
}
}

  

这个方法主要是创建数据库文件

private void setAspNetVersion(string m,string i)
{
string dotnetdir=addBackSlash(Environment.GetEnvironmentVariable("windir"))+"Microsoft.Net";
string[] dirs = Directory.GetDirectories(dotnetdir+"\\Framework\\");
foreach (string d in dirs)
{
int p = d.LastIndexOf("\\v");
if (p >= 0)
{
string v = d.Substring(p + 2);
aspver = v;
string[] mi = v.Split(new char[] { '.' });
if (mi[0].CompareTo(m)==0 && mi[1].CompareTo(i)>=0)
{
//found the directory
string regiis = d + "\\aspnet_regiis.exe";
if (File.Exists(regiis)){
Process proc=new Process();
try{
proc.StartInfo.FileName=regiis;
proc.StartInfo.Arguments = "-s W3SVC/1/ROOT/Lms";
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.StartInfo.CreateNoWindow=true;
proc.Start();
proc.WaitForExit(10000);
}catch (Win32Exception e){ if(e.NativeErrorCode == ERROR_FILE_NOT_FOUND)
{
Console.WriteLine(e.Message + ". Check the path.");
} else if (e.NativeErrorCode == ERROR_ACCESS_DENIED)
{
Console.WriteLine(e.Message +
". You do not have permission to run.");
}
} //catch
}//if file.exists
}//if compare version
}//if pos>=0
}//for each }

  

这个方法主要是利用aspnet_regiis.exe来修改ASP.NET的版本,这个文件在Microsoft.Net目录下

用Inno Setup制作WEB程序安装包的更多相关文章

  1. Inno Setup制作应用程序安装包

    我最近写了一个MFC应用程序,想发给其他的小伙伴玩一玩,直接发了个exe文件过去,结果发现小伙伴那边打不开.原来这个exe文件虽然是MFC静态编译的,但是还依赖了其他几个.dll文件,需要把这几个dl ...

  2. 用inno Setup制作web项目安装包

    http://www.cnblogs.com/xionghui/archive/2012/03/22/2411207.html 用inno Setup制作安装包 新建一个文件夹exambody,放ap ...

  3. [Azure DevOps] 使用 Inno Setup 制作桌面软件安装包

    1. 桌面应用程序的 CI/CD 桌面应用程序的 CI/CD 过程和网站有一些不同,毕竟桌面应用程序的"部署"只是将安装包分发到目标位置,连应用商店都不用上,根据公司的管理流程可以 ...

  4. 用inno Setup做应用程序安装包的示例脚本(.iss文件)(

    用innoSetup做应用程序安装包的示例脚本(.iss文件),具体要看innoSetup附带的文档,好象是pascal语言写的脚本. 示例1(应用程序.exe,客户端安装): ;{089D6802- ...

  5. setup factory 9制作VB程序安装包

    setup factory 使用起来很简单你可以如下:1.你把你刚编译出来的exe和相关的资源文件复制到某一空目录下.把exe文件添加到setup factory里之后,在列表里右键,属性里面可以设置 ...

  6. rhel7 rpmbuild 制作二进制程序安装包(.rpm) 简单示例

    下载rpm-build: # yum install rpm-build 如果上述方式无法安装(没配置网络源,虚拟机下是安装媒介源) 可以用下列方式下载后再安装(实践结果可能版本问题引起的缺少太多的* ...

  7. INNO setup 制作安装包

    1.获取SQLserver安装路径vardbpath:string;rtn:boolean;rtn := RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWA ...

  8. 20 Inno Setup制作安装包的几个问题

    系统开发好之后,通常需要制作成安装包,才能卖给用户.利用Inno Setup的向导可以制作简单的安装包,但是如果要做个好的安装包的话可能会遇到一些麻烦,今日终于抽空解决了,Inno Setup打包的一 ...

  9. 用Inno setup制作以管理员权限启动的安装包

    inno setup制作的安装包,默认是不需要管理员权限启动的.我们制作安装包,往往需要做一些设置工作,这些设置工作可能用到管理员权限.使用Resource Hacker修改inno setup资源, ...

随机推荐

  1. .Net反编译实战

    原文:.Net反编译实战 当你面对一个已经部署好的网站,功能,性能都非常不给力的时候,你会怎么办? 当你尝试去了解这个网站业务逻辑,代码逻辑和数据库逻辑时却发现根本没有任何资料时你会怎么办? 当你准备 ...

  2. mysql压力测试

    1.采用 mysqlslap  压力测试 mysqlslap  --defaults-file=/etc/my.cnf --concurrency=200 --iterations=1 --numbe ...

  3. vmware 新机克隆

    选li72 右键点击------管理-----克隆 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbGlsaTcy/font/5a6L5L2T/fontsi ...

  4. Python基本语法[二],python入门到精通[四] (转)

    写在前面 python你不去认识它,可能没什么,一旦你认识了它,你就会爱上它 回到顶部 v正文开始:Python基本语法 1.定义常量: 之所以上篇博客介绍了定义变量没有一起介绍定义常量,是因为Pyt ...

  5. mysql子查询慢的问题

      当你在用explain工具查看sql语句的运行计划时.若select_type 字段中出现"DEPENDENT SUBQUERY"时,你要注意了.你已经掉入了mysql子查询慢 ...

  6. 开源服务发现项目Zookeeper,Doozer,Etcd

    这篇文章是Jason Wilder对于常见的服务项目发现Zookeeper.Doozer,Etcd所写的一篇博客,其原文地址例如以下:Open-Source Service Discovery. 服务 ...

  7. Linux:闪光的宝石,智慧(下一个)

    2005年4月7日.Linus Torvalds公布了一款新型通用工具软件包,叫做"Git"(the Git source code management system).&quo ...

  8. web富客户端应用下,前端架构、系列(二)。

    序 我们在上面的文章中已经建立起来一个比较简单的 前端架构 虽然这个看上去很简陋. 不过毕竟也是思想的结晶. 从这一篇文章开始,我将陆续完善这一个前端架构.. 重新构思 上一篇我们把前端架构分为3个模 ...

  9. NYNU_省赛选拔题(10)

    题目描述 Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recog ...

  10. Matlab曲面拟合和插值

    插值和拟合都是数据优化的一种方法,当实验数据不够多时常常须要用到这样的方法来绘图. 在matlab中都有特定的函数来完毕这些功能. 这两种方法的确别在于: 当測量值是准确的,没有误差时,一般用插值: ...