|
|
|||||||
So, I am not having any luck retrieving any info from the WindowsInstaller::Installer object in KIX. The following VBscript code lists the MSI product IDs for all products installed on this system: code:That works fine. The same code in KIX, however, does not list anything:Dim installer, Products code:Other COM code such as the WMI example in the KIX 4.02 doc ($Drives = GetObject("winmgmts:").ExecQuery("select Name,DriveType from Win32_LogicalDisk")$installer = CreateObject("WindowsInstaller.Installer") ) does work. I must be missing something very simple. Any help would be greatly appreciated - I don't want to have to use two different languages for a single task. Also, can someone clarify the difference between GetObject() and CreateObject()? TIA |
||||||||
|
|
|||||||
kix32 crashes on this for me... code:with the output of$installer = CreateObject("WindowsInstaller.Installer") quote:on winXP with local admin |
||||||||
|
|
|||||||
It crashes in win2k also... |
||||||||
|
|
|||||||
bump... Anyone gotten this to work?? |
||||||||
|
|
|||||||
Stating the obvious: The error occurs when the FOR EACH line is executed. [ 20 March 2002, 21:03: Message edited by: Howard Bullock ] |
||||||||
|
|
|||||||
Does this help at all ? break on $installer = CreateObject("WindowsInstaller.Installer") for $i = 0 to $installer.Products.count ? $installer.products.item($i) next exit 1 -Shawn |
||||||||
|
|
|||||||
SHAWN Is Da-Man! The code works fine for me... it reports back all the GUID IDs for my installs. Now! what is the purpose of getting these ID numbers? |
||||||||
|
|
|||||||
Ok. I understand the code. But why does the "for each" fail? [ 21 March 2002, 03:05: Message edited by: Howard Bullock ] |
||||||||
|
|
|||||||
That does indeed work but it's extremely slow compared to the same operation in VBscript. You won't see it with Products but if you have Office 2000 or XP installed, you should have several hundreds Components installed. Enumerating them is just too slow: code:And what exactly is the difference between GetObject and CreateObject?break on And to answer NTDOC, the ability to access MSI information would allow a KIX script to see if, say, a particular part of Office was installed and from where and under which Suite, etc. |
||||||||
|
|
|||||||
Try this, its basically what you originally posted and should give you a big performance boost (referencing objects through nested properties and collections can be painfully slow sometimes) break on $installer = CreateObject("WindowsInstaller.Installer") $components = $installer.components for $i = 0 to $components.count ? $components.item($i) next exit 1 -Shawn [ 21 March 2002, 04:19: Message edited by: Shawn ] |
||||||||
|
|
|||||||
Shawn, you seem to have a good handle on this. What is the difference between what you did above and using "For each"? [ 21 March 2002, 04:23: Message edited by: Howard Bullock ] |
||||||||
|
|
|||||||
Not much difference really. Every collection interface has an ITEM and COUNT property. That never changes. It's just that we have numerous ways that we can walk the collection. Here's another one, this might be the fastest work-around method: break on $installer = CreateObject("WindowsInstaller.Installer") $components = $installer.components $count = $components.count while $i < = $count ? $components.item($i) $i=$i+1 loop exit 1 I can't get the less-than sign posted ! Whats up with that ? Anyway... The FOR EACH method just implements an internalized counter and a conditional statement on our behalf, and provides a convenient mechanism for pulling out and assigning the object. Other than that, its exactly the same thing. But in the case of kixtart's builtin enumeration, I think you guys have found a bug. Not too sure if its kixtart or windowsinstaller that is causing the problem. Only one guy can answer so I've sent off an email to Ruud and asked him to comment. -Shawn [ 21 March 2002, 05:08: Message edited by: Shawn ] |
||||||||
|
|
|||||||
Thanks, Shawn BTW, the for loop would need to go to count - 1 as we start from 0. If you could just enlighten me to the GetObject and CreateObject difference, I would greatly appreciate it. And Ruud definately needs to work on some performance issue in the nested collections reference and the foreach which may be the same underlying problem. Until then, I think I'll stick to VBscript for this MSI project. |
||||||||
|
|
|||||||
C'mon Shawn, you know your html. < will get you the < sign. |
||||||||
|
|
|||||||
I tried that. It was still causing grief Let me try here: < Ok that worked, let me edit post... Ok ... it was the equal sign after the < i had to leave off the ; ??? The difference between getobject and createobject. Here's some web info: quote:I like to think that CreateObject creates a running instance of a specific application or a specific DLL or EXE. GetObject is like starting a COM shortcut. Your providing the name (called a moniker) of an abstract thing. Kinda like file associations in Windows. Starting COM objects indirectly. -Shawn [ 21 March 2002, 05:24: Message edited by: Shawn ] |
||||||||
|
|
|||||||
Yeah, go figure... I never bother with the trailing ; Lets try it again here without html <= Can't figure this UBB board out... not very consistent. Some forums you can get away with it, others you can't. Same thing for the copy/paste thingy... for a while after the upgrade, I could just block/copy/paste right into my trusty NotePad... now it doesn''t work again. Maybe it varies from forum to forum... |
||||||||
|
|
|||||||
Yeah, I think its forum related. Plus, Im typing too slowly tonight - Alex - you asked about GetObject and CreateObject - see above. -Shawn |
||||||||
|
|
|||||||
Shawn, Don't you need to destroy the create once finished? -Alex, I understand that, but where is the MAGIC DECODER RING On what all the GUID ID's are linked to. Is there a website that lists these GUIDs and their relationship? This code only returns numbers without even a note on what they link to. How do YOU know what application they belong to? [ 21 March 2002, 09:21: Message edited by: NTDOC ] |
||||||||
|
|
|||||||
GUIDs are not really published anywhere 'central' and the numbers are fairly random. Sometimes each manufacturer will publish the GUIDs of certain apps such as the case for Office XP (there is a KB article on it). However, you can find the GUID for any Product from its MSI file by inspecting the ProductID Property in the Properties table of the MSI file with Orca (the MSI database editor from the MSI SDK) or with the following command: code:You can download MSIRunSQL.vbs fromcscript //NoLogo MSIRunSQL.vbs <msifile> "SELECT Value from Property where Property = 'ProductCode'" http://am.net/LIB/TOOLS/AM/MSIRunSQL.vbs You can also download http://am.net/LIB/TOOLS/AM/MSIdump.vbs - be sure to open the script and read the usage notes at the begining. Dumping everything can take several minutes and will result in a rather large .INI file. I suggest you start with: code:cscript //NoLogo MSIdump.vbs %temp%\test.ini } } 0 1 1 1 |