Andromo - Start Making Apps - Free Signup

Announcement

Collapse

New Forum Software

If you're here, you've found the new home for our forums. There will be some bugs to iron out, so thanks for your patience...
See more
See less

Adding Items to a ListBox or ComboBox from VBScript

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    You can find a thread showing how to populate a ComboBox with data using VBscript here.

    Ulrich

    Comment


    • #3
      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

      Comment

      Working...
      X