Inserting new records into WFWI tables
This issue has been solved. See solution.
All,
I've been struggling ever since I completed my last Windows Installer project with learning how I could insert a new record into a WFWI table using a VBScript. Basically, I would like to insert a new record into the "Updates" table that contains the prior UpgradeCode so my new MSI will replace the older installation version. As always, I am needing to have this functionality scripted to automate the MSI creation process.
Any assistance would be greatly appreciated.
Jack
Documentation
Assuming your are using WIS7 or WPS7, have you looked in the technical documentation folder for the manuals that describe the automation interface?
There are code examples too, which will facilitate your understanding on how to use the wfwi.document object with VBScript to insert content into tables.
There are also previous postings in the wise forums which show examples of automation code - feel free to search for them.
If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.
Thank you
Thank you for pointing me in the right direction. I'll review the documentation for an answer to my problem.
Jack
Still having trouble...
All,
After a couple of days spent reading and rereading help files that I had already read before, searching the forums & the web, I am still having trouble with adding a new row to a table via VBScript. I'm fairly certain it is simply a matter of finding the correct syntax... Regardless, I don't feel as though I am much closer to solving this one than I was during my original post and would like to ask again for assistance.
Here's what I am trying to do. I need to add a row to the Upgrade table in my Windows Installer script. My current script looks like this...
**********************************************************************************************************
WSIFile = WScript.Arguments(0) '// 1st argument is the path to .wsi
UpdateToVersion = WScript.Arguments(1) '// 2nd argument is the version
UpdateToProductCode = WScript.Arguments(2) '// 3rd argument is the new product code
UpdateToHostURL = WScript.Arguments(3) '// 4th argument is the host url
Set WFWI = CreateObject("WfWI.Document")
WFWI.Open(WSIFile)
Set tbl1 = WFWI.WTables("WiseModuleConfiguration")
tbl1.WRows.Row("WiseUpdate.58949955_0765_4225_AB94_EA84F43B417A,Version").WColumns("Value").Data = UpdateToVersion
tbl1.WRows.Row("WiseUpdate.58949955_0765_4225_AB94_EA84F43B417A,SettingsURL").WColumns("Value").Data = UpdateToHostURL
Set tbl2 = WFWI.WTables("Property")
tbl2.WRows.Row("ProductVersion").WColumns("Value").Data = UpdateToVersion
if UpdateToProductCode = "yes" then
Set TypeLib = CreateObject("Scriptlet.TypeLib")
NewGUID = TypeLib.Guid
Set TypeLib = Nothing
Set oldGUID = tbl2.WRows.Row("UpgradeCode").WColumns("Value")
tbl2.WRows.Row("ProductCode").WColumns("Value").Data = NewGUID
tbl2.WRows.Row("UpgradeCode").WColumns("Value").Data = NewGUID
Set tbl3 = WFWI.WTables("Upgrade")
tbl3Row = tbl3.NewRRow()
tbl3Row(0) = oldGUID
tbl3Row(1) = "1.0.0"
tbl3Row(2) = "9.9.9"
tbl3Row(3) = 1033
tbl3Row(4) = 733
tbl3Row(6) = "_PASSED_IN_VERSION_"
tbl3.Rows.Add(tbl3Row)
end if
WFWI.Compile(WSIFile)
**********************************************************************************************************
The part I am having trouble with is where I am creating a new row that I will later insert into the existing table. The exact error message is: VBScript runtime error: Object doesn't support this property or method: 'tbl3.NewRRow'.
I have tried several variations along this theme all without much luck...
tbl3Row = tbl3.WRows.NewRRow()
tbl3Row = tbl3.NewWRow()
tbl3Row = tbl3.NewRRow
tbl3Row = WFWI.WTables("Upgrade").NewRRow()
tbl3Row = WFWI.WTables("Upgrade").NewWRow()
...and the list goes on.
Any assistance is greatly appreciated.
Jack
I am a complete no-mark...
...as far as Wise Automation is concerned. Keep meaning to get into it, never have. Not sure I'll bother now, given the state of play, Wise-wise.
However, from reading the rather spartan documentation, I'd observe that there doesn't appear to be an NewRRow method. There *is* a NewWRow method, though.
Also, that method takes a parameter, vAddToTable. The doc says cryptically:
"bAddToTable specifies if the row is added to the table or created, but not added. Default value is TRUE, to add to table."
(Perhaps the author was Spanish: their 'b' and 'v' sounds are similar, aren't there?)
Lastly, I'm not sure how the return is handled so if the above fails, try adding brackets to your first use of 'tbl3Row':
tbl3Row() = tbl3.NewWRow(True)
Don't know why 'x' happened? Want to know why 'y' happened? Use ProcMon and it will tell you.
Think about using http://www.google.com before posting.
Thank you for your feedback...
...and I understand about the "NewRRow" -vs- "NewWRow" confusion on my part. Here is what I found in the WiseAutomation help file for the WRow.AddRow method:
**********************************************************************************************************
WRows:: AddRowWRow)
Adds a given WRow to the WRows collection. Rows are created using NewRRow().
Parameters
Remarks
Adds a row created by NewWRow to a table if it has not already been added.
**********************************************************************************************************
The first comment after the header references creating rows using the NewRRow() method, while the remarks comments states using the NewWRow method. So, I tried both! Neither seemed to help much however I did seem to get further when I used the NewWRow method.
Trying your suggestions (Did I thank you already? If not, Thank You!!) I still received errors. :(
tbl3Row() = tbl3.NewWRow(true) - Returned "Microsoft VBScript runtime error: Type mismatch: 'tbl3Row'"
tbl3Row = tbl3.NewWRow(true) - Returned "Windows Installer Editor: Unable to find column."
I even tried "True" thinking it may be a case sensitivity problem, no luck there either.
Regards,
Jack
Well, that first error at
Well, that first error at least tells you that it's not expecting to dump into an array!
What does [code]Set tbl3Row = tbl3.NewWRow() [/code] get you?
Don't know why 'x' happened? Want to know why 'y' happened? Use ProcMon and it will tell you.
Think about using http://www.google.com before posting.
Hi VBScab, I am trying to run
That seemed to do the trick!
I know I tried that before now but this time it seemed to do the trick!
Here is the "working" script that I am using to insert a new record into the Upgrade table while also updating other tables. The purpose of this script was so I can automate updating the Wise script from Final Builder allowing me to compile & package all in one easy to manage method.
**********************************************************************************************************
WSIFile = WScript.Arguments(0) '// 1st argument is the path to .wsi
UpdateToVersion = WScript.Arguments(1) '// 2nd argument is the version
UpdateToProductCode = WScript.Arguments(2) '// 3rd argument is the new product code
UpdateToHostURL = WScript.Arguments(3) '// 4th argument is the host url
Set WFWI = CreateObject("WfWI.Document")
WFWI.Open(WSIFile)
Set tbl1 = WFWI.WTables("WiseModuleConfiguration")
tbl1.WRows.Row("WiseUpdate.58949955_0765_4225_AB94_EA84F43B417A,Version").WColumns("Value").Data = UpdateToVersion
tbl1.WRows.Row("WiseUpdate.58949955_0765_4225_AB94_EA84F43B417A,SettingsURL").WColumns("Value").Data = UpdateToHostURL
Set tbl2 = WFWI.WTables("Property")
tbl2.WRows.Row("ProductVersion").WColumns("Value").Data = UpdateToVersion
if UpdateToProductCode = "yes" then
Set TypeLib = CreateObject("Scriptlet.TypeLib")
NewGUID = TypeLib.Guid
Set TypeLib = Nothing
Set oldGUID = tbl2.WRows.Row("UpgradeCode").WColumns("Value")
tbl2.WRows.Row("ProductCode").WColumns("Value").Data = NewGUID
tbl2.WRows.Row("UpgradeCode").WColumns("Value").Data = NewGUID
Set tbl3 = WFWI.WTables("Upgrade")
Set tbl3Row = tbl3.NewWRow()
tbl3Row(0) = oldGUID
tbl3Row(1) = "1.0.0"
tbl3Row(2) = "9.9.9"
tbl3Row(3) = "1033"
tbl3Row(4) = "733"
tbl3Row(6) = "_PASSED_IN_VERSION_"
end if
WFWI.Compile(WSIFile)
**********************************************************************************************************
In addition to adding the "set" in the NewWRow command, I had to also remove the call to Rows.Add as the new row had already been added by this time.
I had a feeling it would be related to syntax and was right.
Thanks again for your assistance!
Regards,
Jack
Hi Jack
Hi Jack, I am attempting to do exactly what you were struggling with...
I am trying to automate the build using final builder.
I have to write a script that will write to the .wsi file and would save the product version in this file. then compile it and make the .msi
As you know there is no action in final builder that would actually does that for you.
so I just grabbed a "Run Script " action and started my VB scripting!! using the first line of your solution but unfortunately it throws an error and doesn't like
the [argument()]....
This is how I started to implement your solution:
I have typed the following line in the "on Execute" tab in "script editor" of Action "Run Script"
WSIFile = WScript.arguments(0); the .argument part is not even supported by vb script....
it gives an error and tell me end of statement expected etc
any thoughts
Thank you in advance
SZ
Try Google
Have a search on wscript.arguments in google. This should clarify matters for you.
If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.
Add some error-trapping
At present, every line of your code assumes that it will execute properly. Experience tells us that, at some point, it won't. For example, how are you handling empty arguments? What, you think they'll never be empty?
Don't know why 'x' happened? Want to know why 'y' happened? Use ProcMon and it will tell you.
Think about using http://www.google.com before posting.
SZ, I understand the problem
SZ,
I understand the problem you are having. Basically, the script above is expecting a few arguments passed into it. Specifically:
1. The path to the MSI file to modify
2. The version number to insert into the table formatted in my case as "1.0.0" or whatever.
3. Indicator for updating the version code (this is a "yes", "no" parameter, though anything other than "yes" is "no"!)
4. The URL you want to use for updates (we have both a test and live environment so I needed to create 2 setups, one for each).
So, when I exectute the script from Final Builder I do it like this... Using an "Execute Program" action I set the following values on the Program tab:
Program file: "%windir%\system32\cscript.exe "
Execute Parameters:
Parameter: ""C:\Program Files\Altiris\Wise\Windows Installer Editor\Projects\WiseUpdateProductVersion.vbs" "C:\Program Files\Altiris\Wise\Windows Installer Editor\Projects\ICeSetup.wsi" %SETUP_VERSION% %SETUP_NEW_PRODUCT_CODE% "test1.iwantinsurance.com/ice3/iceupgrade.ini""
Start In: "C:\Program Files\Altiris\Wise\Windows Installer Editor\Projects"
Options I check: "Wait for Completion"; Program Exit Code Must be "Equal To 0"; Log Output. I do not select the Hide Window option.
Everything else is pretty much left as default. You can see that in this example the parameters include several variables from my final builder script. I use Input Boxes to enter the version number and if the version code should be updated to pass to the vb script parameter string.
Let me know if this doesn't fill in all the blanks for you.
Jack
SZ, Sorry, but i did not see
SZ,
Sorry, but i did not see your embedded post above giving additional informaiton about what you are trying to do. Try this. Save this as a vbs file:
**********************************************************************************************************
WSIFile = WScript.Arguments(0) '// 1st argument is the path to .wsi
UpdateToVersion = WScript.Arguments(1) '// 2nd argument is the version
Set WFWI = CreateObject("WfWI.Document")
WFWI.Open(WSIFile)
Set tbl1 = WFWI.WTables("Property")
tbl1.WRows.Row("ProductVersion").WColumns("Value").Data = UpdateToVersion
WFWI.Compile(WSIFile)
**********************************************************************************************************
Now in your Final Builder script, select an "Execute Program" action using the following information on the Program Tab:
Program file: "%windir%\system32\cscript.exe "
Execute Parameters:
Parameter: ""C:\Program Files\Altiris\Wise\Windows Installer Editor\Projects\WiseUpdateProductVersion.vbs" "C:\Program Files\Altiris\Wise\Windows Installer Editor\Projects\ICeSetup.wsi" %SETUP_VERSION%"
Start In: "C:\Program Files\Altiris\Wise\Windows Installer Editor\Projects"
Options I check: "Wait for Completion"; Program Exit Code Must be "Equal To 0"; Log Output. I do not select the Hide Window option.
Of course you will need to alter the directories and file names to match your situation. Anyway, that should do the trick for you. When I was testing this outside the Final Builder script, I just created a shortcut on my desktop calling the cscript.exe and passing in my parameters. Then after I had made any changes I just clicked the link. That helped me quite a bit.
I agree with VBScab though, I should have added some error checking in there.
Jack
Would you like to reply?
Login or Register to post your comment.