• Create an IIS application.
  • Create a new IIS application pool and set it's .NET version to 4.
  • Set the application pool of the new application to the new application pool.
procedure CreateIISVirtualDir();
var
IIS, WebSite, WebServer, WebRoot, VDir: Variant;
ErrorCode: Integer;
begin
{ Create the main IIS COM Automation object } try
IIS := CreateOleObject('IISNamespace');
except
RaiseException('Please install Microsoft IIS first.'#13#13'(Error ''' + GetExceptionMessage + ''' occurred)');
end; { Connect to the IIS server } WebSite := IIS.GetObject('IIsWebService', IISServerName + '/w3svc');
WebServer := WebSite.GetObject('IIsWebServer', IISServerNumber);
WebRoot := WebServer.GetObject('IIsWebVirtualDir', 'Root'); { (Re)create a virtual dir } try
WebRoot.Delete('IIsWebVirtualDir', 'eipwebv4');
WebRoot.SetInfo();
except
end; VDir := WebRoot.Create('IIsWebVirtualDir', 'eipwebv4');
VDir.AccessRead := True;
VDir.AccessScript := TRUE;
VDir.AppFriendlyName := 'Easy-IP Web Client';
VDir.Path := ExpandConstant('{app}');
try
VDir.AppPoolId := 'Classic .NET AppPool';
except
end; VDir.AppCreate(True);
VDir.SetInfo();
end;
var
global_AppCmdFilePath :String;
global_IsIIS7 :Boolean;
global_WebSites :SiteList;
global_WebSiteName :String;
global_vDir :String;
global_AppCmdExitCode :Integer; const
IISServerName = 'localhost';
IISApplicationPoolName = 'Test Pool'; ERROR_NOT_FOUND = 1168;
ERROR_NOT_SUPPORTED = 50; MD_APPPOOL_IDENTITY_TYPE_LOCALSYSTEM = 0;
MD_APPPOOL_IDENTITY_TYPE_LOCALSERVICE = 1;
MD_APPPOOL_IDENTITY_TYPE_NETWORKSERVICE = 2;
MD_APPPOOL_IDENTITY_TYPE_SPECIFICUSER = 3; MD_LOGON_INTERACTIVE = 0;
MD_LOGON_BATCH = 1;
MD_LOGON_NETWORK = 2;
MD_LOGON_NETWORK_CLEARTEXT = 3; function ExecAppCmd(params :String) :Boolean;
var
execSuccessfully :Boolean;
resultCode :Integer;
begin
execSuccessfully := Exec('cmd.exe', '/c ' + global_AppCmdFilePath + ' ' + params, '', SW_HIDE, ewWaitUntilTerminated, resultCode); global_AppCmdExitCode := resultCode; Result := execSuccessfully and (resultCode = 0);
end; function CreateVirtualDirectoryForIIS6(physicalPath :String) :String;
var
IIS, webService, webServer, webRoot, vDir, vDirApp :Variant;
appPools, appPool :Variant;
webSiteId :String;
begin
webSiteId := GetWebSiteIdByName(global_WebSiteName); // Create the main IIS COM Automation object.
IIS := CreateOleObject('IISNamespace'); // Get application pools.
appPools := IIS.GetObject('IIsApplicationPools', 'localhost/W3SVC/AppPools'); try
// Check if the application pool already exists.
appPool := appPools.GetObject('IIsApplicationPool', IISApplicationPoolName);
except
// Crete the application pool.
try
appPool := appPools.Create('IIsApplicationPool', IISApplicationPoolName); appPool.LogonMethod := MD_LOGON_NETWORK_CLEARTEXT;
appPool.AppPoolIdentityType := MD_APPPOOL_IDENTITY_TYPE_NETWORKSERVICE; appPool.SetInfo();
except
Result := 'Failed to create an apllication pool.';
Exit;
end;
end; // Connect to the IIS server.
webService := IIS.GetObject('IIsWebService', IISServerName + '/w3svc'); // Get the website.
webServer := webService.GetObject('IIsWebServer', webSiteId);
webRoot := webServer.GetObject('IIsWebVirtualDir', 'Root'); // Delete the virtual dir if it already exists.
try
webRoot.Delete('IIsWebVirtualDir', global_vDir);
webRoot.SetInfo();
except
// An exception will be raised if there is not such a website.
end; // Create the virtual directory.
try
vDir := WebRoot.Create('IIsWebVirtualDir', global_vDir); vDir.AccessRead := True;
vDir.AccessScript := True;
vDir.AppFriendlyName := 'Test friendly name';
vDir.Path := physicalPath; vDir.AppCreate(False); vDir.SetInfo();
except
Result := 'Failed to create a virtual directory.';
Exit;
end; // Assign the application pool to the virtual directory.
try
vDir := webRoot.GetObject('IIsWebVirtualDir', global_vDir); vDir.AppPoolId := IISApplicationPoolName; vDir.SetInfo();
except
Result := 'Failed to assign the application pool to the virtual directory.';
Exit;
end;
end; function CreateVirtualDirectoryForIIS7(physicalPath :String) :String;
var
tempFileName :String;
appPoolList :String;
createAppPool :Boolean;
begin
// Delete the application if it already exists.
if not ExecAppCmd(Format('delete app "%s/%s"', [global_WebSiteName, global_vDir])) then
begin
if (global_AppCmdExitCode <> ERROR_NOT_FOUND) and (global_AppCmdExitCode <> ERROR_NOT_SUPPORTED) then
begin
Result := 'Failed to delete the application. ' + GetErrorMessageByCode(global_AppCmdExitCode);
Exit;
end;
end; // Check if the application pool already exists.
tempFileName := ExpandConstant('{tmp}\AppPoolNames.txt'); ExecAppCmd(Format('list apppool "%s" > "%s"', [IISApplicationPoolName, tempFileName])); if (LoadStringFromFile(tempFileName, appPoolList)) then
begin
createAppPool := (Pos(IISApplicationPoolName, appPoolList) = 0);
end
else
begin
createAppPool := True;
end; // Create the application pool.
if (createAppPool) then
begin
if not ExecAppCmd(Format('add apppool /name:"%s" /managedRuntimeVersion:v4.0', [IISApplicationPoolName])) then
begin
Result := 'Failed to add the application pool. ' + GetErrorMessageByCode(global_AppCmdExitCode);
Exit;
end;
end; // Create the application.
if not ExecAppCmd(Format('add app /site.name:"%s" /path:"/%s" /physicalPath:"%s" /applicationPool:"%s"', [global_WebSiteName, global_vDir, physicalPath, IISApplicationPoolName])) then
begin
Result := 'Failed to add the application. ' + GetErrorMessageByCode(global_AppCmdExitCode);
Exit;
end; Result := '';
end;

How do I create an IIS application and application pool using InnoSetup script的更多相关文章

  1. IIS负载均衡-Application Request Route详解第二篇:创建与配置Server Farm(转载)

    IIS负载均衡-Application Request Route详解第二篇:创建与配置Server Farm 自从本系列发布之后,收到了很多的朋友的回复!非常感谢,同时很多朋友问到了一些问题,有些问 ...

  2. IIS负载均衡-Application Request Route详解第四篇:使用ARR实现三层部署架构(转载)

    IIS负载均衡-Application Request Route详解第四篇:使用ARR实现三层部署架构 系列文章链接: IIS负载均衡-Application Request Route详解第一篇: ...

  3. IIS负载均衡-Application Request Route详解第一篇: ARR介绍(转载)

    IIS负载均衡-Application Request Route详解第一篇: ARR介绍 说到负载均衡,相信大家已经不再陌生了,本系列主要介绍在IIS中可以采用的负载均衡的软件:微软的Applica ...

  4. IIS提示Server Application Unavailable

    浏览器访问网站,IIS提示Server Application Unavailable,我的解决方式是进入IIS管理界面,找到对应的站点,之后重启这个站点.

  5. IIS负载均衡-Application Request Route详解第一篇: ARR介绍

    IIS负载均衡-Application Request Route详解第一篇: ARR介绍 说到负载均衡,相信大家已经不再陌生了,本系列主要介绍在IIS中可以采用的负载均衡的软件:微软的Applica ...

  6. devmapper: Thin Pool has 162394 free data blocks which is less than minimum required 163840 free data blocks. Create more free space in thin pool or use dm.min_free_space option to change behavior

    问题: 制作镜像的时候报错 devmapper: Thin Pool has 162394 free data blocks which is less than minimum required 1 ...

  7. 关于Application.Lock…Application.Unlock有什么作用?

    因为Application变量里一般存储的是供所有连接到服务器的用户共享的信息(就像程序中所说的 "全局变量 "), 由于是全局变量,所以就容易出现两个或者多个用户同时对这一变量进 ...

  8. c#中退出WinForm程序包括有很多方法,如:this.Close(); Application.Exit();Application.ExitThread(); System.Environment.Exit(0);

    本文实例总结了C#中WinForm程序退出方法技巧.分享给大家供大家参考.具体分析如下: 在c#中退出WinForm程序包括有很多方法,如:this.Close(); Application.Exit ...

  9. solr File Upload "Unsupported ContentType: application/vnd.ms-excel Not in: [application/xml, application/csv, application/json, text/json, text/csv, text/xml, application/javabin]",

    今天在用solr管理界面导入文件时报错:"Unsupported ContentType: application/vnd.ms-excel  Not in: [application/xm ...

随机推荐

  1. 联想G480安装CentOS电缆驱动器

    最近.联想G480 32本机安装现场CentOS 6.5. 发现.总是无法使用有线网络. 必须安装必要的驱动,搜集了资料,安装过程例如以下: 1. 必备的软件 安装前,须要下列的软件依赖包. sudo ...

  2. atitit.为什么技术的选择方法java超过.net有前途

    atitit.为什么技术的选择方法java超过.net有前途 #----有没有法律依据不同的铜需求... 通常有开发效率,需要在稳定性.. 笔者 老哇爪 Attilax 艾龙,  EMAIL:1466 ...

  3. JavaScript面向对象旅程(下)

    JavaScript面向对象旅程 剪不断,理还乱,是离愁. 前面已经提到过新语言开发的两个步骤,分别是:一.定义基本的数据类型,完善结构化编程语言的设计:二.为函数类型绑定this的概念,好在对象的方 ...

  4. 使用批处理文件命令行方式快速启动和停止IIS、SqlServer

    原文:使用批处理文件命令行方式快速启动和停止IIS.SqlServer 虽然现在内存便宜了,但是自己还是嫌自己的512M内存太小,没办法,后台运行的东西太多了,有很多都是有用的没法关闭的.IIS和SQ ...

  5. Java内存模型-jsr133规范介绍(转)

    最近在看<深入理解Java虚拟机:JVM高级特性与最佳实践>讲到了线程相关的细节知识,里面讲述了关于java内存模型,也就是jsr 133定义的规范. 系统的看了jsr 133规范的前面几 ...

  6. 怎样在多线程中使用JNI?

    假设你想了解JNI在怎样在多线程下使用 假设你在子线程使用JNI时遇到findClass不能找到目标Class,而在主线程下却能找到该Class的问题.或是GetEnv返回NULL的问题 假设你想多学 ...

  7. CentOS 7安装配置Apache HTTP Server

    原文 CentOS 7安装配置Apache HTTP Server   RPM安装httpd # yum -yinstall httpd //安装httpd会自动安装一下依赖包: apr apr-ut ...

  8. asp.net学习之GridView七种字段

    原文:asp.net学习之GridView七种字段 asp.net中GridView绑定到数据源时,可以自动显示数据源的各个字段.只要设定其AutoGenerateColumns为TRUE即可.但这, ...

  9. hdu 5066 Harry And Physical Teacher(Bestcoder Round #14)

    Harry And Physical Teacher Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Ja ...

  10. js 正则学习小记之匹配字符串

    原文:js 正则学习小记之匹配字符串 今天看了第5章几个例子,有点收获,记录下来当作回顾也当作分享. 关于匹配字符串问题,有很多种类型,今天讨论 js 代码里的字符串匹配.(因为我想学完之后写个语法高 ...