///////////////////////////////////////////////////////////////////////////////
// //
// 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;
// //
// 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;