Custom page failed on IIS 5.0
Hello,
I'm writing an installer for my package and I have a problem
with IIS 5.0 (win2000).
I want to show the list of available server running on IIS in a custom page.
I use the latest NSIS 2.43 and the same script on a Win2000 (IIS 5.0), XP (IIS 5.1) and Server 2003 (IIS 6.0)
It works fine on XP and 2003 but not on 2000, I really don't understand why.
Is there something specific to IIS 5.0 ???
I have a custom page
Page custom PickWebsite ValidateCustom
to choose between IIS server available.
To get this list, I use a vbs script :
Function GetWebsites
; Output the VBScript
FileOpen $4 "$PLUGINSDIR\GetWebsites.vbs" w
FileWrite $4 'Set IISOBJ = getObject("IIS://localhost/" & "w3svc")$\n'
FileWrite $4 'Set objFSO = CreateObject("Scripting.FileSystemObject")$\n'
FileWrite $4 'Set objTextFile = objFSO.OpenTextFile("$PLUGINSDIR\websites.ini", 8, True)$\n'
FileWrite $4 'AllSites = ""$\n'
FileWrite $4 'for each Web in IISOBJ$\n'
FileWrite $4 'if (Web.Class = "IIsWebServer") then$\n'
FileWrite $4 'Set IISWebSite = getObject("IIS://localhost/" & "w3svc" & "/" & Web.Name)$\n'
FileWrite $4 'Set IISWebSiteRoot = getObject("IIS://localhost/" & "w3svc" & "/" & Web.Name & "/root")$\n'
FileWrite $4 'AllSites = AllSites & "|" & IISWebSite.ServerComment$\n'
FileWrite $4 'objTextFile.WriteLine("[" & IISWebSite.ServerComment & "]")$\n'
FileWrite $4 'objTextFile.WriteLine("Path=" & IISWebSiteRoot.Path)$\n'
FileWrite $4 'objTextFile.WriteLine("Name=" & Web.Name)$\n'
FileWrite $4 'objTextFile.WriteLine("LogDir=" & IISWebSite.LogFileDirectory & "/w3svc/" & Web.Name & "/")$\n'
FileWrite $4 'objTextFile.WriteLine("")$\n'
FileWrite $4 'Set IISWebSiteRoot = nothing$\n'
FileWrite $4 'Set IISWebSiteLogDir = nothing$\n'
FileWrite $4 'Set IISWebSite = Nothing$\n'
FileWrite $4 'end if$\n'
FileWrite $4 'next$\n'
FileWrite $4 'objTextFile.WriteLine("[Websites]")$\n'
FileWrite $4 'objTextFile.WriteLine("AllSites=" & Right(AllSites, Len(AllSites)-1))$\n'
FileWrite $4 'objTextFile.Close$\n'
FileWrite $4 'Set objFSO = Nothing$\n'
FileWrite $4 'Set objTextFile = Nothing$\n'
FileWrite $4 'Set IISOBj = Nothing$\n'
FileClose $4
; Execute the script
nsExec::Exec /TIMEOUT=20000 '"$SYSDIR\cscript.exe" "$PLUGINSDIR\GetWebsites.vbs"'
FunctionEnd
which return the list of server available in AllSites.
(ie AllSites = "Default Web Server|MyDomain.com Server")
When I populate this value in pick_website.ini
function WriteIni
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Settings' 'NumFields' '4'
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Field 1' 'Type' 'Label'
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Field 1' 'Text' 'Please Select which Web Site to set the application to use:'
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Field 1' 'Left' '0'
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Field 1' 'Right' '-1'
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Field 1' 'Top' '0'
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Field 1' 'Bottom' '10'
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Field 2' 'Type' 'Droplist'
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Field 2' 'Text' 'droplist'
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Field 2' 'ListItems' ''
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Field 2' 'Left' '25'
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Field 2' 'Right' '150'
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Field 2' 'Top' '10'
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Field 2' 'Bottom' '22'
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Field 3' 'Type' 'label'
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Field 3' 'Text' 'Directory for the application (leave blank for default) :'
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Field 3' 'Left' '0'
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Field 3' 'Right' '-1'
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Field 3' 'Top' '30'
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Field 3' 'Bottom' '40'
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Field 4' 'Type' 'text'
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Field 4' 'Text' 'webPath'
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Field 4' 'State' ''
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Field 4' 'Left' '25'
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Field 4' 'Right' '150'
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Field 4' 'Top' '40'
WriteIniStr '$PLUGINSDIR\pick_website.ini' 'Field 4' 'Bottom' '52'
FunctionEnd
The PickWebsite is here :
Function PickWebsite
Call GetWebsites
Call WriteIni
ReadINIStr $0 "$PLUGINSDIR\websites.ini" "Websites" "AllSites"
WriteINIStr "$PLUGINSDIR\pick_website.ini" "Field 2" "ListItems" $0
!insertmacro MUI_HEADER_TEXT "Webserver Configuration" "Choose the website and path that your installation will reside at."
!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "pick_website.ini"
!insertmacro MUI_INSTALLOPTIONS_SHOW
FunctionEnd
Any help welcome !
Laurent