• 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. PHP 闭包函数 function use 使用方法实例

    /** * @param string $hisStart * @param string $hisEnd * @param int $range * @param string $format * ...

  2. Docker container communication with ovs

    2台宿主机,192.168.11153,192.168.1.154 安装OVS rpm -ivh openvswitch-2.4.0-1.x86_64.rpm #预先下载的 配置OVS 1. 按照上一 ...

  3. NSIS常用代码整理

    原文 NSIS常用代码整理 这是一些常用的NSIS代码,少轻狂特意整理出来,方便大家随时查看使用.不定期更新哦~~~ 1 ;获取操作系统盘符 2 ReadEnvStr $R0 SYSTEMDRIVE ...

  4. 【cocos2d-js公文】十八、Cocos2d-JS v3.0物业风格API

    1. 新的API风格 我们直接来看看你能够怎样使用Cocos2d-JS v3.0: 曾经的API 新的API node.setPosition(x, y); node.x = x; node.y = ...

  5. POJ 2777 Count Color(段树)

    职务地址:id=2777">POJ 2777 我去.. 延迟标记写错了.标记到了叶子节点上.. . . 这根本就没延迟嘛.. .怪不得一直TLE... 这题就是利用二进制来标记颜色的种 ...

  6. angularjs从零开始(一)

    简介   AngularJS是为了克服HTML在构建应用上的不足而设计的.HTML是一门很好的为静态文本展示设计的声明式语言,但要构建WEB应用的话它就显得乏力了.所以我做了一些工作(你也可以觉得是小 ...

  7. 阐述linux IPC(两):基于socket进程间通信(下一个)

    [版权声明:尊重原创.转载请保留源:blog.csdn.net/shallnet 要么 .../gentleliu,文章学习交流.请勿用于商业用途]     其中两个进程通信,有两个过程,以彼此的过程 ...

  8. ios swift学习日记1-Swift 初见

    最近ios的swift语言似乎火了,我没有objectc基金会,但在此之前有cjava的基础的.从这几天開始学习ios的swift语言.后期以博客形式公布.这里提供一本翻译的英文版的swif书籍. 还 ...

  9. java maven quartz exampe 实用指南

    pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w ...

  10. C#操作Xml:如何定义Xsd文件

    Xml Schema的用途 1. 定义一个Xml文档中都有什么元素 2. 定义一个Xml文档中都会有什么属性 3. 定义某个节点的都有什么样的子节点,可以有多少个子节点,子节点出现的顺序 4. 定义元 ...