惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
V
V2EX
爱范儿
爱范儿
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Martin Fowler
Martin Fowler
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Apple Machine Learning Research
Apple Machine Learning Research
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
宝玉的分享
宝玉的分享
Last Week in AI
Last Week in AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
罗磊的独立博客
小众软件
小众软件
Vercel News
Vercel News
博客园 - 司徒正美
阮一峰的网络日志
阮一峰的网络日志
V
Visual Studio Blog
J
Java Code Geeks
P
Proofpoint News Feed
MongoDB | Blog
MongoDB | Blog
B
Blog
美团技术团队
量子位

博客园 - codingsilence

更新部分字段 NHibernate 都是分号惹的祸(ORA-00911: invalid character) 降低Winform 内存占用 FARPOINT 常见用法 比较Double型数据时的注意事项 WinForm中获取鼠标当前位置 查看SQL Server日志 WinForm winform动态生成菜单 WinForm 从XML中动态加载菜单的示例 “轻松加愉快”地实现并使用IComparer接口 WinForm 选择器 C#程序实现动态调用DLL的研究 WCF 的 WebGet 方式 WCF WebGet WebInvoke WCF Jquery 调用 开源选型关注点 在64位Windows的IIS上开启32位程序支持(转) Oracle grant用户授权 ODP.NET开发和部署的相关问题 Client使用c#和odp.net连接server oracle
installshiled 创建iis应用程序池和站点
codingsilence · 2011-08-07 · via 博客园 - codingsilence

 ///////////////////////////////////////////////////////////////////////////////
// //
// Function: CreateVirDir //
// //
// Purpose: This function creates an IIS Virtual Directory //
// //
///////////////////////////////////////////////////////////////////////////////

function CreateVirDir(IISSite, SiteDir)
BOOL SiteExisted;
object objIIS_Root, objVirtDir, objAppPool, objIIS_WS, objSchedule;
STRING svAppPool, strMsg, svT, svHold, svCmd, svProg, svParms[500], svOut;
STRING szField1, svF1, svF2;
NUMBER svPoolStatus, nLineNum;

begin

svAppPool = "M5WebServices";

if @IFX_PRODUCT_NAME = "M5 Pages, Components and Help" then
svAppPool = "M5AppServices";
endif;

if (svIISVer = "6") then
if (SYSINFO.WINNT.bWinServer2003 = TRUE) then
set objIIS_Root = CoGetObject("IIS://localhost/W3SVC/AppPools", "");
if (IsObject(objIIS_Root)) then
try
set objAppPool = objIIS_Root.GetObject("IISApplicationPool", svAppPool);
svPoolStatus = TRUE;
catch
set objAppPool = objIIS_Root.Create("IISApplicationPool", svAppPool);
svPoolStatus = FALSE;
objAppPool.SetInfo();
endcatch;

if (IsObject(objAppPool)) then
// In minutes
objAppPool.PeriodicRestartTime = 1740;
if svAppPool = "M5WebServices" then
// In number of events
// objAppPool.PeriodicRestartRequests = 4000;
// In bytes
// objAppPool.PeriodicRestartMemory = 512000;
// In bytes
// objAppPool.PeriodicRestartPrivateMemory = 196608;
endif;
objAppPool.SetInfo();
endif;
set objAppPool = NOTHING;
set objIIS_Root = NOTHING;
endif;
endif;

set objIIS_Root = CoGetObject("IIS://localhost/W3SVC/1/Root", "");
if (IsObject(objIIS_Root)) then
try
set objVirtDir = objIIS_Root.GetObject("IISWebVirtualDir", IISSite);
SiteExisted = TRUE;
catch
set objVirtDir = objIIS_Root.Create("IISWebVirtualDir", IISSite);
SiteExisted = FALSE;
endcatch;
if (IsObject(objVirtDir)) then
// Do not recreate the CrystalExports site in case the output
// for reports has been manually changed (file sharing in use
// multiple web servers.
if (IISSite = "CE_BIN" && SiteExisted) then
svLine = "Business Objects Exports Bin directory already exists. It will not be recreated.";
nResult = WriteLine(nvLogFileHandle, svLine);
elseif (IISSite = "Uploads" && SiteExisted) then
svLine = "Uploads directory already exists. It will not be recreated.";
nResult = WriteLine(nvLogFileHandle, svLine);
else
try
objVirtDir.Path = SiteDir;
objVirtDir.AccessRead = TRUE;
objVirtDir.AccessScript = TRUE;
if (SYSINFO.WINNT.bWinServer2003 = TRUE) then
objVirtDir.AspMaxRequestEntityAllowed = 10485760; //10 MB
objVirtDir.AspBufferingLimit = 5242880; //5 MB
endif;
objVirtDir.AccessWrite = FALSE;
objVirtDir.AspEnableParentPaths = TRUE;
objVirtDir.EnableDirBrowsing = FALSE;
objVirtDir.AspScriptLanguage = "JScript";
objVirtDir.AppFriendlyName = IISSite;
objVirtDir.AppIsolated = 2;
objVirtDir.AspAllowSessionState = FALSE;
if (SYSINFO.WINNT.bWinServer2003 = TRUE) then
objVirtDir.AppPoolID = svAppPool;
endif;
objVirtDir.SetInfo();
objVirtDir.AppCreate(TRUE);
objVirtDir.SetInfo();
catch
svLine = "Unable to create Virtual Directory " + IISSite + ". You will have to create it manually.";
nResult = WriteLine(nvLogFileHandle, svLine);
endcatch;
endif;
endif;
endif;
else
// IIS 7 setup
// Check for the correct application pool first
svCmd = "cmd";
svProg = " /C " + WINDIR ^ "system32" ^ "inetsrv" ^ "appcmd.exe";
svOut = szAppPath ^ "m5iis.txt";
svT = ' list apppool /name:"' + svAppPool + '" >>' + svOut;
svParms = svProg + svT;
svLine = "Checking for " + svAppPool + " application pool";
nResult = WriteLine(nvLogFileHandle, svLine);
nResult = LaunchAppAndWait(svCmd, svParms, WAIT | LAAW_OPTION_HIDDEN);
if (FileGrep (svOut, svAppPool, szField1,
nLineNum, RESTART) != 0) then
svLine = "Need to create application pool " + svAppPool;
nResult = WriteLine(nvLogFileHandle, svLine);
svF1 = ' add apppool /name:"' + svAppPool + '" /managedRunTimeVersion:"v2.0" /managedPipelineMode:"Classic" ';
// svF2 = '/autoStart:"true" /recycling.periodicRestart.requests:"4000" /recycling.periodicRestart.time:"24:00:00" /recycling.periodicRestart.memory:"512000" /recycling.periodicRestart.privateMemory:"196608"';
svF2 = '/autoStart:"true"';
svT = svF1 + svF2;
svHold = svF1 + svF2;
svParms = svProg + svT;
svLine = "Creating " + svAppPool + " application pool";
nResult = WriteLine(nvLogFileHandle, svLine);
nResult = LaunchAppAndWait(svCmd, svParms, WAIT | LAAW_OPTION_HIDDEN);
svT = ' list apppool /name:"' + svAppPool + '" >>' + svOut;
svParms = svProg + svT;
nResult = LaunchAppAndWait(svCmd, svParms, WAIT | LAAW_OPTION_HIDDEN);
if (FileGrep (svOut, svAppPool, szField1,
nLineNum, RESTART) != 0) then
svLine = "Unable to create application pool " + svAppPool;
nResult = WriteLine(nvLogFileHandle, svLine);
svLine = " command used was " + svHold;
nResult = WriteLine(nvLogFileHandle, svLine);
bProblem = TRUE;
endif;
endif;
nResult = DeleteFile(svOut);
// Now add the IIS application
svCmd = "cmd";
svProg = " /C " + WINDIR ^ "system32" ^ "inetsrv" ^ "appcmd.exe";
svOut = szAppPath ^ "m5iis.txt";
svT = ' list app http://localhost/' + IISSite + '" >>' + svOut;
svParms = svProg + svT;
svLine = "Checking for " + IISSite + " IIS application";
nResult = WriteLine(nvLogFileHandle, svLine);
nResult = LaunchAppAndWait(svCmd, svParms, WAIT | LAAW_OPTION_HIDDEN);
if (FileGrep (svOut, IISSite, szField1,
nLineNum, RESTART) = 0) then
if (IISSite = "CE_BIN") then
svLine = "Business Objects Exports Bin directory already exists. It will not be recreated.";
nResult = WriteLine(nvLogFileHandle, svLine);
return 0;
elseif (IISSite = "Uploads") then
svLine = "Uploads directory already exists. It will not be recreated.";
nResult = WriteLine(nvLogFileHandle, svLine);
return 0;
endif;
endif;
svT = ' add app /site.name:"Default Web Site" /path:/' + IISSite + ' /physicalPath:' + SiteDir + ' /applicationPool:' + svAppPool;
svParms = svProg + svT;
svLine = "Creating IIS Application " + IISSite + " using paramters of " + svT;
nResult = WriteLine(nvLogFileHandle, svLine);
nResult = LaunchAppAndWait(svCmd, svParms, WAIT | LAAW_OPTION_HIDDEN);
nResult = DeleteFile(svOut);
endif;

return 0;
end;