Scripting Question

Use WFWI to edit MST

06/20/2008 6751 views
In a nutshell, what I'm trying to do is brand a MST file with company branding. I already have a WSI template created with branding that I use for SetupCaptures, but when creating MST files, I always have to add the branding manually.

The final product is going to be an HTA page with fill in's for the branding information, then the vbscript will use WFWI to open the MST, add Features, Components, Properties, etc so that the packager does not have to do this manally.

I tried creating a Universal Transform, but Properties only port with the {GUID} appended and that negates the use of the Property.

When I run it with either oWFWI object created I get an error. What am I missing or is there an easier way to open the MST an edit the items I need to edit?

My script so far, looks like this:
Const rrHKeyLocalMachine = 2
Const rdString = 0Const fdtVisibleAndCollapsed = 32512
Const roCreateUpdateKeyValue = 0
Const roRemoveKeyValueOnInstall = 5
Const faFavorLocal = 0
Const flAlwaysInstall = 1

Dim strProductVersion, strProductName, strProdName, strProductVendor, strAuthor, strUserName, strMSTFile
Dim oWFWI, oTblFeature, oTblComponent, oTblRegistry, objFeature, objComponentDim oFso:Set oFso = CreateObject("Scripting.FileSystemObject")

strProductVersion = "1.0"
strProductName = "IT Test Package 1.0"
strProdName = "Test"
strProductVendor = "IT"
strAuthor = "ME"
sItRegKey = "SOFTWARE\IT Template\Packages"

'Open wise project file
KillProcess "wfwi.exe"
Set oWFWI = CreateObject("WfWi.Document")
'Set oWFWI = CreateObject("WFWI.WFWIProject")
strMSTFile = inputbox("Enter Path & Filename to MST", "MST Branding Tool")

Const C_COMPONENT = "Registry_Branding"
Const C_FEATURE = "IT_Customizing"

'create registry branding
Set objComponent = oWFWI.AddComponent(C_COMPONENT, "INSTALLDIR")

objComponent.AddRegistryKey rrHKeyLocalMachine, sItRegKey, "ApplicationName", "[ProdName]", rdString, roCreateUpdateKeyValue
objComponent.AddRegistryKey rrHKeyLocalMachine, sItRegKey, "ApplicationVersion", "[ProductVersion]", rdString, roCreateUpdateKeyValue
objComponent.AddRegistryKey rrHKeyLocalMachine, sItRegKey, "ApplicationVendor", "[Manufacturer]", rdString, roCreateUpdateKeyValue
objComponent.AddRegistryKey rrHKeyLocalMachine, sItRegKey, "InstallDate", "[Date]", rdString, roCreateUpdateKeyValue
objComponent.AddRegistryKey rrHKeyLocalMachine, sItRegKey, "InstallTime", "[Time]", rdString, roCreateUpdateKeyValue
objComponent.AddRegistryKey rrHKeyLocalMachine, sItRegKey, "-", "", rdString, roRemoveValuesUninstall

Set objFeature = oWFWI.AddFeature(C_FEATURE)
objFeature.Title = C_FEATURE
objFeature.Description = C_FEATURE
objFeature.DisplayType = fdtVisibleAndExpanded
objFeature.Attribute = faFavorLocal
objFeature.Level = flAlwaysInstall
objFeature.RestartIIS = True
objFeature.Directory = oWFWI.Directories("ProgramFilesFolder")

oWFWI.AddProperty "ProdName", strProdName
oWFWI.AddProperty "ALLUSERS", 1
oWFWI.AddProperty "REBOOT", "ReallySuppress"
oWFWI.AddProperty "Manufacturer", strProductVendor
oWFWI.AddProperty "MsiLogging", "v"

' set values for summary information stream
Dim oTblSummary, oRow
Set oTblSummary = oWFWI.WTables("Summary")
For Each oRow In oTblSummary.WRows
If UCASE(oRow("Field")) = "TITLE" Then oRow("Value") = strProductName
If UCASE(oRow("Field")) = "AUTHOR" Then oRow("Value") = strUserName
If UCASE(oRow("Field")) = "SUBJECT" Then oRow("Value") = "Global Software Package"
If UCASE(oRow("Field")) = "KEY WORDS" Then oRow("Value") = "IT"
'save project file
'release object variables
Set oWFWI = Nothing

Sub KillProcess(ProcToKill)
On Error Resume Next
Dim oWMI, oSWBem, oItem, cItems
Dim sComputer, sUserName, sPassword, propValue

sComputer = "."
sUserName = ""
sPassword = ""

Set oSWBem = CreateObject("WbemScripting.SWbemLocator")
Set oWMI = oSWBem.ConnectServer(sComputer, "\root\CIMV2" ,sUserName, sPassword)
Set cItems = oWMI.ExecQuery("Select * from Win32_Process",,48)
For Each oItem in cItems
If InStr(LCase(oItem.Name), LCase(ProcToKill)) >= 1 Then
End If
End Sub
0 Comments   [ + ] Show comments


Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

All Answers

If you're doing this in pure vbscript as it appears, hats off to you, but look at msft's sample script files on how to build msi's and mst's from scratch.

but since you have wise why not use a macro, which is almost the same as vbscipt but does a lot of msi/mst manipulation.

unofortunately this is a little documented and I think underused part of Wise, but there are a few samples and some documentation. the editor has typeahead context senstive help which can help somewhat. if you're interested I can email you a sample wbs script i worked up with company name etc. which you can customize.
Answered 06/20/2008 by: aogilmor
9th Degree Black Belt

I've also considered renaming the MST to WSI, making my modifications, and then renaming to MST. Has anyone tried this method with any success?

Could the MST be opened as a database and simply have the tables updated???
Answered 06/20/2008 by: Arieya
Yellow Belt

So I actually was able to answer my own question with my last pondering thought.

The script above works, if you add a line to make a copy of the MST and rename it to WSI (fso.copyfile strMSTFile, strWSIFile), then it opens the MST file, and is able to use the Set oWFWI = CreateObject("WFWI.WFWIProject") object to add all the necessary branding that you want to add.

It turns out, that as long as there is a WSI file to edit available to the object, it can access the MST directly to make the changes and save it for you.

Happy coding!
Answered 06/23/2008 by: Arieya
Yellow Belt

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login


This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ