Alternative to "For Each" iteration

Discussion in 'Scripting' started by Danny, May 31, 2004.

  1. Danny

    Danny Guest

    Is there another way of browsing all the SWbemObject objects in a SWbemObjectSet without using the "For Each" iteration

    The scripting tool I am using does not have such an iteration, so I would need to use the the Count propety and the Item() method to browse every object

    Is this possible

    Thanks in advance.
    Danny, May 31, 2004
    1. Advertisements

  2. AFAIK, no... There *is* an SWbemObjectSet.tem(index) method, but it does
    not support numeric indices (see the documentation).

    What language are you using that supports COM access but doesn't support COM
    collection enumeration?
    Michael Harris \(MVP\), May 31, 2004
    1. Advertisements

  3. Danny

    Danny Guest

    Hi Micheal

    Thanks for confirming my suspicion

    I am using InstallShield script..

    So I can determine if a process is running (Count > 0), but I can't terminate said process. It's very frustrating

    I know I could make an external call to a VB script file, but I would rather execute everything directly with InstallShield script


    Danny, May 31, 2004
  4. I am using InstallShield script...

    In your InstallShield script, you could (I assume) create a WScript.Shell
    instance and use the WshShell.Run method (3rd argument True to wait for
    completion) to run a WSH hosted helper VBScript to do the WMI part of the
    job. You could even use FSO from within the InstallShield script to
    dynamically write the helper script to a local temporary *.vbs file (deleted
    after execution) if you don't have a reliable UNC path where you would store
    a persistent copy.
    Michael Harris \(MVP\), May 31, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.