How do I create an IIS application and application pool using InnoSetup script
- 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的更多相关文章
- IIS负载均衡-Application Request Route详解第二篇:创建与配置Server Farm(转载)
IIS负载均衡-Application Request Route详解第二篇:创建与配置Server Farm 自从本系列发布之后,收到了很多的朋友的回复!非常感谢,同时很多朋友问到了一些问题,有些问 ...
- IIS负载均衡-Application Request Route详解第四篇:使用ARR实现三层部署架构(转载)
IIS负载均衡-Application Request Route详解第四篇:使用ARR实现三层部署架构 系列文章链接: IIS负载均衡-Application Request Route详解第一篇: ...
- IIS负载均衡-Application Request Route详解第一篇: ARR介绍(转载)
IIS负载均衡-Application Request Route详解第一篇: ARR介绍 说到负载均衡,相信大家已经不再陌生了,本系列主要介绍在IIS中可以采用的负载均衡的软件:微软的Applica ...
- IIS提示Server Application Unavailable
浏览器访问网站,IIS提示Server Application Unavailable,我的解决方式是进入IIS管理界面,找到对应的站点,之后重启这个站点.
- IIS负载均衡-Application Request Route详解第一篇: ARR介绍
IIS负载均衡-Application Request Route详解第一篇: ARR介绍 说到负载均衡,相信大家已经不再陌生了,本系列主要介绍在IIS中可以采用的负载均衡的软件:微软的Applica ...
- 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 ...
- 关于Application.Lock…Application.Unlock有什么作用?
因为Application变量里一般存储的是供所有连接到服务器的用户共享的信息(就像程序中所说的 "全局变量 "), 由于是全局变量,所以就容易出现两个或者多个用户同时对这一变量进 ...
- c#中退出WinForm程序包括有很多方法,如:this.Close(); Application.Exit();Application.ExitThread(); System.Environment.Exit(0);
本文实例总结了C#中WinForm程序退出方法技巧.分享给大家供大家参考.具体分析如下: 在c#中退出WinForm程序包括有很多方法,如:this.Close(); Application.Exit ...
- 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 ...
随机推荐
- 余弦信号DFT频谱分析(继续)
以前谈到序列的实际长度可以通过零填充方法加入,使得最终增加N添加表观分辨率. 但它并没有解决泄漏频率的问题. 根本原因在于泄漏窗口选择的频率. 由于矩形窗突然被切断,频谱旁瓣相对幅度过大,造成泄漏分量 ...
- k8s with flanneld
三台机器 kmaster 192.168.1.201 kslave202 192.168.1.202 kslave203 192.168.1.203 安装好k8s 1. 在Node机器上安装flann ...
- GRUB三步通(转)
GRUB三步通 ################### GRUB的优点 ################### GRUB 是引导装入器(boot loader) -- 它负责装入内核并引导 Linux ...
- Azure File Service in IIS
微软Azure的Storage套件中提供了新的服务File Service,让我们运行在Azure中的程序都能共享存储,一个存储账号共享的没有上线,但每个共享的上限是5G.由于File Service ...
- python抓取网络内容
最近想做研究互联网来获取数据,只是有一点python,让我们来看一个比较简单的实现. 例如,我想抓住奥巴马的每周演讲http://www.putclub.com/html/radio/VOA/pres ...
- Matlab与.NET基于类型安全的接口混合编程入门
原文:[原创]Matlab与.NET基于类型安全的接口混合编程入门 如果这些文章对你有用,有帮助,期待更多开源组件介绍,请不要吝啬手中的鼠标. [原创分享]Matlab.NET混编调用Figure窗体 ...
- VAXVOIP SDK Licensekey
Insert the following key to the SDK with SetLicenseKey call: VAXVOIP.COM-191P238P55P253P97P229P51P76 ...
- NET动态调用WebService
NET动态调用WebService 这不是一篇教你了解WebService的博文,也不是对WebService的深入理解, 这是一篇教你在开发过程中,如果动态的调用WebService一个方法. 在比 ...
- 仅当使用了列的列表,并且 IDENTITY_INSERT 为 ON 时,才能在表中为标识列指定显式值问题
今天在处理数据库过程中碰到这样的问题在插入一条数据到表中 系统报这样的错误 仅当使用了列的列表,并且 IDENTITY_INSERT 为 ON 时,才能在表中为标识列指定显式值问题 表有一列是自增长的 ...
- POJ 1006 Biorhythms 中国的法律来解决剩余的正式
这个问题以前用模拟的方法来解决亚军,正如溶液是一个通用的解决方案. 这里使用数学方法:剩下的孙子法(当然,被称为中国剩余法).由于建议的孙子.所以也承认外国的孙子是数学家. 参考数论建议大家学习的专业 ...