In WiX I have a vbScript for use in a Custom Action that will return ListItems of Network Printers. I want to use these ListItems to populate the ComboBox at Install Time because I won't know the printer names on the users system until after starting the installation.
Here is the vbScript. It currently outputs to a text file pending how to work with it to answer my question.
Const ForWriting = 2
Set objNetwork = CreateObject("Wscript.Network")
strName = objNetwork.UserName
strDomain = objNetwork.UserDomain
strUser = strDomain & "\" & strName
strText = ""
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colPrinters = objWMIService.ExecQuery _
("Select * From Win32_Printer Where Local = FALSE")
For Each objPrinter in colPrinters
strText = strText & "<ListItem Text=""" & objPrinter.Name &""" Value="""& objPrinter.Name &"""/>" & vbcrlf
Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile _
("C:\Scripts\Printers.txt", ForWriting, True)
objFile.Write strText
objFile.Close
And this is the output :
<ListItem Text="\\xfiles\Canon iR3030 PCL6" Value="\\xfiles\Canon iR3030 PCL6"/>
<ListItem Text="\\xfiles\HP2110" Value="\\xfiles\HP2110"/>
I am hoping to be able to use this output as ListItems for my ComboBox.
<Control Type="ComboBox" Property="cboPrinters_Prop" Id="cboPrinters" Width="206" Height="16" X="19" Y="139" ComboList="yes">
<ComboBox Property="cboPrinters_Prop">
<ListItem Text="" Value=""/>
</ComboBox>
</Control>
If there is a better way or I am approaching this all wrong(I keep trying to think like a developer) please feel free to correct me. I am thick skinned... :)