Use WFWI to edit MST
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")
oWFWI.Open(strMSTFile)
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")
objFeature.AddComponent(objComponent)
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"
Next
'save project file
oWFWI.Save(strMSTFile)
'release object variables
Set oWFWI = Nothing
WScript.Quit
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
oItem.terminate
End If
Next
End Sub
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")
oWFWI.Open(strMSTFile)
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")
objFeature.AddComponent(objComponent)
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"
Next
'save project file
oWFWI.Save(strMSTFile)
'release object variables
Set oWFWI = Nothing
WScript.Quit
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
oItem.terminate
End If
Next
End Sub
0 Comments
[ + ] Show comments
Answers (3)
Please log in to answer
Posted by:
aogilmor
16 years ago
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.
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.
Posted by:
Arieya
16 years ago
Posted by:
Arieya
16 years ago
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!
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!
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.