Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2012
    Posts
    6

    Adding Items to a ListBox or ComboBox from VBScript

    I am having a few problems with trying to use VBScript (which will be packaged with the MSI) to populate a listbox or a combobox on one of the dialogs.

    I'm having to use VBScript as havenít found a way I can get a list of attached devices in LUA.

    I need to obtain the list and feed this back into the combobox or list box that is going to exist on a dialog in the MSI. Is there a quick way of adding items to the lists?

  2. #2
    Join Date
    Apr 2005
    Location
    Tabo„o da Serra
    Posts
    3,554
    You can find a thread showing how to populate a ComboBox with data using VBscript here.

    Ulrich

  3. #3
    Join Date
    Sep 2012
    Posts
    6
    Thanks for the direction Ulrich.

    After a lot of pain I simply could not get 'msiViewModifyInsertTemporary' to work. I did adjust the script you pointed me to to add the values i needed I managed to build the string to feed into 'msiViewModifyInsertTemporary' ok but the error was on trying to submit the strind using the 'msiViewModifyInsertTemporary' function.

    This is the code I used which I couldnt get to work:

    Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
    Set colItems = objWMIService.ExecQuery("Select * from Win32_PnPSignedDriver " & _
    "WHERE DeviceID like 'USBPRINT%' ")
    Set oView = MSI.Database.OpenView("SELECT * FROM `ComboBox`")
    oView.Execute
    r = 0
    For Each objItem In colItems
    r = r + 1
    sDevice = objItem.DeviceID
    sUSB = Right(sDevice, (Len(sDevice) - InStrRev(sDevice, "&", -1, 1)))
    Set oRec = Session.Installer.CreateRecord(4)
    oRec.StringData(1) = "COMBO1"
    oRec.IntegerData(2) = r
    oRec.StringData(3) = objItem.DeviceName
    oRec.StringData(4) = sUSB
    oView.Modify msiViewModifyInsertTemporary, oRec
    Next
    oView.Close


    This was created to get a list of the printers attached via USB and feeed them into 'COMBO1'

    I managed to get it to work via another method. Submitting the list in a query to the database as follows

    Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
    Set colItems = objWMIService.ExecQuery("Select * from Win32_PnPSignedDriver " & _
    "WHERE DeviceID like 'USBPRINT%'")
    r = 0
    For Each objItem In colItems
    r = r + 1
    sDevice = objItem.DeviceID
    sUSB = Right(sDevice, (Len(sDevice) - InStrRev(sDevice, "&", -1, 1)))
    MsgBox objItem.DeviceName & " " & sUSB
    ComboProp = "COMBO1"
    ComboOrder = r
    ComboValue = objItem.DeviceName
    ComboText = sUSB
    query = "INSERT INTO `ComboBox` (`Property`, `Order`, `Value`, `Text`) VALUES ('" & ComboProp & "', " & ComboOrder & ", '" & ComboValue & "', '" & ComboText & "') TEMPORARY"
    Set view = Session.Database.OpenView(query)
    view.Execute
    next
    view.close


    This was the only way in which I could populate the ComboBox with the values I needed.

    I hope that this practise is ok and I hope this will help people in future hope may come across the same issue.

    Thanks again

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts