/bundles/itninjaweb/img/Breadcrumb_cap_w.png
First off I am using Wise Installation Studio to make my installer and using their default dialogs etc. I don't know if that helps. I want to be able to save what features the user has decided to install or not install during a custom installation. At what point in the installation sequence is the FeatureState updated with the user's changes? I assume I will need to place my custom action after this to save the feauture state?
0 Comments   [ - ] Hide Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
Answer this question or Comment on this question for clarity

Answers

0
May I ask why you need to know?
Answered 08/21/2008 by: AngelD
Red Belt

Please log in to comment
0
this should give you the detail you want



Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Const msiInstallStateAbsent = 2
Const msiInstallStateLocal = 3
Const msiInstallStateSource = 4
Const msiInstallStateDefault = 5
strSourceDir = session.property("INSTALLDIR")
sLogFile = "d:\setups\Install.log"
sXmlFile = "d:\setups\" & trim(session.property("ProductName")) & ".xml"
Set oInstaller = session.installer
Set oShell = CreateObject("Wscript.Shell")
Set oXmlDoc= CreateObject("Microsoft.XMLDOM")
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oLogfile = oFSO.CreateTextFile(sLogFile, ForWriting)
oXmlDoc.PreserveWhiteSpace = True
Set oXmlPI = oXmlDoc.CreateProcessingInstruction("xml", "version=""1.0""")
oXmlDoc.AppendChild(oXmlPI)
Set oXmlRoot = oXmlDoc.CreateElement("Environment")
oXmlDoc.AppendChild(oXmlRoot)
Set oNodeInstallDetails = oXmlDoc.CreateElement("InstallDetail")
oXmlRoot.AppendChild(oNodeInstallDetails)
Set oNodeAppDetails = oXmlDoc.CreateElement("PackageDetail")
oXmlRoot.AppendChild(oNodeAppDetails)
Set oNodeComponents = oXmlDoc.CreateElement("Components")
oNodeAppDetails.AppendChild(oNodeComponents)
Set oNodeCustomAction = oXmlDoc.CreateElement("CustomActions")
oNodeAppDetails.AppendChild(oNodeCustomAction)
AddNodeAttribute oNodeAppDetails, "ApplicationName", session.property("ProductName")
AddNodeAttribute oNodeAppDetails, "ApplicationVersion", session.property("ProductVersion")
AddNodeAttribute oNodeInstallDetails, "ApplicationInstaller", session.property("%Username")
AddNodeAttribute oNodeInstallDetails, "InstallDate", date
AddNodeAttribute oNodeInstallDetails, "InstallLocation", session.property("%Computername")
sUsername = oShell.ExpandEnvironmentStrings("%USERNAME%")
Set oView = session.database.openview("Select * FROM File")
oView.Execute
Do
Set oRecord = oView.Fetch
if oRecord is nothing then
exit do
end if
sComponent = oRecord.StringData(2)
cComponentState = session.componentRequestState(sComponent)

If session.componentRequestState(sComponent) > 1 Then
sFilePath = "[#" & oRecord.StringData(1) & "]"
sFilePathValue = FormatRecord(sFilePath)

sCompFldr = "[$" & oRecord.StringData(2) & "]"
sCompFldrValue = FormatRecord(sCompFldr)
sFileSize = oRecord.StringData(4)
sFileVersion = oRecord.StringData(5)
oLogFile.Writeline "FilePath: " & sCompFldrValue
oLogFile.Writeline "FileFldr: " & sFilePathValue
oLogFile.Writeline ""

CreateFile oRecord.StringData(2), sFilePathValue, sCompFldrValue, sFileSize, sFileVersion
'
End If
Loop
Set oView1 = session.database.openview("Select Action FROM CustomAction")
oView1.Execute
Do
Set oRecord1 = oView1.Fetch
If oRecord1 Is Nothing Then
exit do
end if
sActionName = oRecord1.StringData(1)

Set oView2 = session.database.openview("Select Condition FROM InstallExecuteSequence WHERE Action ='" & sActionName & "'")
oView2.Execute
Do
Set oRecord2 = oView2.Fetch
If oRecord2 Is Nothing Then
Exit Do
End If

intResult = session.evaluateCondition(oRecord2.StringData(1))

If IntResult = 1 Or intResult = 2 Then
Set oNodeNewCA = oXmlDoc.CreateElement("CA")
oNodeCustomAction.AppendChild(oNodeNewCA)
AddNodeAttribute oNodeNewCA, "Name", oRecord1.StringData(1)
AddNodeAttribute oNodeNewCA, "Condition", oRecord2.StringData(1)
End If

Loop
Loop
oXmlDoc.Save(sXmlFile)
'********************************************************************************
' Function: MSI Format Record
'
' Inputs: sRecordName
'
' Output: Resolved record value
'
'--------------------------------------------------------------------------------
Function FormatRecord(sRecordName)
On Error Resume Next
Set oFormatRecord = oInstaller.CreateRecord(1)
oFormatRecord.ClearData
oFormatRecord.StringData(0) = sRecordName
FormatRecord = Session.FormatRecord(oFormatRecord)
Set oFormatRecord = Nothing
'
end function
'********************************************************************************
' Function: XMLNodeExists
'
' Inputs: sXQuery
'
' Output: Boolean value to see of node is present
'
'--------------------------------------------------------------------------------
Function XMLNodeExists(sXQuery)
XMLNodeExists = True
Set oExistNode = oXmlDoc.DocumentElement.SelectSingleNode(sXQuery)
If oExistNode Is Nothing Then XMLNodeExists = False
set oExistNode = Nothing
End function
'********************************************************************************
' Function: Create XML Component Node
'
' Inputs: sNode - name of XML Component node to create
'
' Output: none
'
'--------------------------------------------------------------------------------
Function CreateComponent(sNode)
If Not XMLNodeExists("//Environment/PackageDetail/Components/" & sNode) Then
Set oNodeNewComponent = oXmlDoc.CreateElement(sNode)
oNodeComponents.AppendChild(oNodeNewComponent)
else
set oNodeNewComponent = oXmlDoc.SelectSingleNode("//Environment/PackageDetail/Components/" & sNode)
end if
set CreateComponent = oNodeNewComponent
set oNodeNewComponent = nothing
End function
'********************************************************************************
' Function: CreateFile
'
' Inputs: sComp - Component node to add file detail to
' sFile - File name details
' sFolder - File folder path
' sFileSize - File size
' sFileVersion - File version
'
' Output: none yet
'
'--------------------------------------------------------------------------------
Function CreateFile(sComp, sFile, sFolder, sFileSize, sFileVersion)

set oNodeCurrentComponent = CreateComponent(sComp)
Set oNodeNewFile = oXmlDoc.CreateElement("File")
oNodeCurrentComponent.AppendChild(oNodeNewFile)
AddNodeAttribute oNodeNewFile, "Filename", sFile
AddNodeAttribute oNodeNewFile, "Filedir", sFolder
AddNodeAttribute oNodeNewfile, "Filesize", sFileSize
AddNodeAttribute oNodeNewfile, "FileVersion", sFileVersion
set oNodeCurrentComponent = nothing
set oNodeNewFile = nothing
End function
'********************************************************************************
' Function: AddNodeAttribute
'
' Inputs: oNode - XML Node to add stuff into.
' sAttName - Attribute name to add
' sValue - Attribute value to add
'
' Output: Resolved record value
'
'--------------------------------------------------------------------------------
Function AddNodeAttribute(oNode, sAttName, sValue)
set oAttrib = oXmlDoc.CreateAttribute(sAttName)
oAttrib.Value = sValue
oNode.Attributes.SetNamedItem oAttrib
End Function

Answered 08/24/2008 by: jmcfadyen
Fifth Degree Black Belt

Please log in to comment