cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
rfitzpat
Level 4

Can a VB script custom action either return a value or set a property?

I have a VB script that returns the highest IIS website on a webserver.
I plan to use this information to make sure my new website is on the next number higher.
(using InstallShield 2012 Basic MSI)

Can the VB script set InstallShield Property values?
‘VBScript Stored in custom action’



OPTION EXPLICIT

' http://www.40fingers.net/WeblogsNews/Weblogs/tabid/58/ID/21/language/en-US
' return the highest number website so install can take the next number
' usage : cscript.exe gethighestwebsitenumber.vbs //NOLOGO
' 2

DIM CRLF, TAB
DIM strServer
DIM objWebService
DIM strSiteIds
DIM strSiteHighestId

strSiteIds = ""
TAB = CHR( 9 )
CRLF = CHR( 13 ) & CHR( 10 )

strServer = "localhost"

' WScript.Echo "Enumerating websites on " & strServer & CRLF
SET objWebService = GetObject( "IIS://" & strServer & "/W3SVC" )
EnumWebsites objWebService

' Writes a message to the installer log
Function LogInfo(msg)
Dim rec, fso
Set fso = CreateObject ("Scripting.FileSystemObject")
Set rec = Session.Installer.CreateRecord(1)
rec.StringData(0) = "ServerInstall: " & msg
LogInfo = Session.Message(&H04000000, rec)

set rec = Nothing

set fso = Nothing
End Function

SUB EnumWebsites( objWebService )
DIM objWebServer, objWeb, strBindings, strBaseInfo

FOR EACH objWebServer IN objWebService
IF objWebserver.Class = "IIsWebServer" THEN
set objWeb = getObject(objWebServer.adsPath & "/Root")
' strSiteIds = strSiteIds & strComma & objWebserver.Name
strSiteHighestId = objWebserver.Name
END IF
NEXT
'Wscript.StdOut.Write strSiteHighestId
LogInfo "Highest Web Site ID: " & strSiteHighestId
END SUB


Robert

Edited to make VB script work and write Web Site ID to MSI log file.
Labels (1)
0 Kudos
1 Reply
TsungH
Level 12

You can use the following code to set Windows Installer property value during UI Sequence and Immediate Execute Sequence.
Session.Property("PROPERTYNAME") = "PropertyValue"
0 Kudos