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 ...
随机推荐
- ACdream 1427 Nice Sequence
主题链接:http://115.28.76.232/problem? pid=1427 Nice Sequence Time Limit: 12000/6000MS (Java/Others)Memo ...
- ContentMode 几个属性
版权声明:本文博客原创文章,博客,未经同意,不得转载.
- android 推断应用程序是系统程序还是用户程序
直接上代码: AppInfo.java <span style="font-size:18px;">package com.example.packages; publ ...
- CentOS7 安装NFS SSH免密码登陆
配置5台虚拟机 ip为192.168.1.160 - 164,使用160作为共享服务器 使用yum安装nfs 以及rpcbind,有很多文章介绍,这里不再赘述 一.启动服务 1.启动rpcbind s ...
- android怎么在launcher改动内置apk的icon
找到launcher下的IconCache中加入变量用来存储要改动apk的包名 及要改动成的icon private String[] className = {"com.google.an ...
- UVA11080- Place the Guards(二分图染色)
题目链接 题意:放最少的士兵去监视全部的道路, 但士兵不可相邻,符合的话,就输出最少的士兵数,否则输出-1 思路:事实上就是二分图染色,即黑白染色,然后选择黑白染色最少的那个颜色累加,但要注意可能有多 ...
- Android 4.4(KitKat)表格管理子系统 - 骨架
原文地址:http://blog.csdn.net/jinzhuojun/article/details/37737439 窗体管理系统是Android中的主要子系统之中的一个.它涉及到App中组件的 ...
- ubuntu 14.04 hadoop eclipse 0配置基本环境
动人的hadoop第二天.构造hadoop该环境还花了两天时间,在这里写自己配置的过程,我希望能帮助! 我将文中用到的全部资源都分享到了 这里,点开就能下载,不须要一个个的找啦! 当中有<Ha ...
- Codeforces 135A-Replacement(思维)
A. Replacement time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
- Bringing up interface eth0: Device eth0 does not seem to be present, delaying initialization
跑 service network restart NIC出现无法启动,他说,没有发现 Bringing up interface eth0: Device eth0 does not seem t ...