• 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. mysql 解压缩和赋权

    拉开拉链mysql紧凑根文件夹 注意ini配置文件的内容 basedir = D:\mysql-5.6.17-winx64  datadir = D:\mysql-5.6.17-winx64  por ...

  2. c# Ftp下载程序源代码解析

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  3. atittit.表单验证性质的原则和实施,以及选择和定义自己的兼容easyui dsl窗体身份验证规则

    atittit.表单验证性质的原则和实施,以及选择和定义自己的兼容easyui dsl规则的表单验证 1. 需求,表单验证须要弹框式,但眼下easyui ms绑定死了tooltip式样 1 2. 表单 ...

  4. JavaEE(24) - JAAS开发安全的应用

    1. 安全域.角色和用户组 容器提供的两种安全性控制:声明式安全控制和编程式安全控制 安全域是指用户.用户组和ACL的逻辑集合.服务器支持的两种常用安全域:RDBMS安全域和文件系统安全域. 2. J ...

  5. js关于propotype的一些事-------Day62

    近期在忙着搬家,忙忙活活的收拾这收拾那,原以为自己东西了了,谁知道东西是越收拾越多,各种崩溃啊..... 昨日在记录js动态生成表格的经典方式时,用到了createDocumentFragment() ...

  6. Cocos2d-X中的坐标系

    在Cocos2d-x中坐标能够分成四种: 1.GL坐标体系:GL坐标体系左下角为坐标原点,X轴向右,Y轴向上 2.UI坐标体系:UI坐标体系左上角为坐标原点,X轴向右,Y轴向上. .世界坐标体系:是窗 ...

  7. swift UI特殊培训38 与滚动码ScrollView

    有时我们适合页面的全部内容,我们需要使用ScrollView,额外的内容打通滚动. 什么样的宽度和高度首先,定义,健身器材轻松. let pageWidth = 320 let pageHeight ...

  8. 字符串属性 NSMutableAttributedString/NSAttributedString

    因为iOS7新出的NSTextStorge是NSMutableAttributedString的子类.所以要用好NSTextStorage.首先要学好NSMutableAttributedString ...

  9. OCP读书笔记(23) - 题库(ExamC)

    200.Which operation requires that you create an auxiliary instance manually before executing the ope ...

  10. SSIS从理论到实战,再到应用(3)----SSIS包的变量,约束,常用容器

    原文:SSIS从理论到实战,再到应用(3)----SSIS包的变量,约束,常用容器 上期回顾: SSIS从理论到实战,再到应用(2)----SSIS包的控制流   首先我们来看看包里面的变量 SSIS ...