After some research (and help) I found that the problem was caused by the web site number (a value in the IIS config settings in the project). I had set this value to 0 thinking InstallShield would just use the next available web site number. However, this is not so. I don't know why, but if the port was used by another site, it used that site's number. If the port wasn't in use, it would used the next number. As far as I know, there isn't a mechanism to use the next available. So, I wrote a function in InstallScript that calls out the the IIS admin script absutil.vbs to get the numbers in use and return the next one.
Here is the function:
//---------------------------------------------------------------------------
// GetNextWebSiteNumber
//
// Author: Yevi
//
// Description: This function returns the next available web site number based
// on entries for current web sites in IIS. The admin script adsutil.vbs is
// used the query current web sites.
// If there is an error, the function returns -1.
//---------------------------------------------------------------------------
function GetNextWebSiteNumber()
NUMBER nResult;
NUMBER nvTempWebSiteNumber;
NUMBER nWebSiteNumber;
NUMBER nvFileHandle;
NUMBER nNumPos;
STRING szProgName;
STRING szProgParams;
STRING szFileDir;
STRING szFileName;
STRING svLine;
STRING svSiteNum;
begin
nvTempWebSiteNumber = -1;
nWebSiteNumber = nvTempWebSiteNumber;
szFileDir = SUPPORTDIR;
szFileName = "websiteenum.txt";
// Run the adsutil.vbs script and get all the web sites. Put the
// output into a file.
szProgName = WINDIR^"system32\\cscript.exe";
szProgParams = " C:\\inetpub\\AdminScripts\adsutil.vbs ENUM /p W3SVC > " + szFileDir^szFileName;
if (LaunchAppAndWait(szProgName, szProgParams, WAIT) >= 0) then
// Open the file with the web sites and find the number
// of the last one.
OpenFileMode(FILE_MODE_NORMAL);
if (!OpenFile (nvFileHandle, szFileDir, szFileName) < 0) then
while GetLine (nvFileHandle, svLine) = 0
if (svLine % "W3SVC/") then
nNumPos = StrFind(svLine, "/");
StrSub(svSiteNum, svLine, nNumPos, 10);
StrToNum(nvTempWebSiteNumber, svSiteNum);
if (nvTempWebSiteNumber > nWebSiteNumber) then
nWebSiteNumber = nvTempWebSiteNumber;
endif;
endif;
endwhile;
CloseFile(nvFileHandle);
nWebSiteNumber = nWebSiteNumber + 1;
endif;
endif;
return (nWebSiteNumber);
end;
Hopefully this will save you time and pain.
*EDIT* This doesn't quite work. Look for the posted correction.
No comments:
Post a Comment