Page 1 of 1 1
Topic Options
#160949 - 2006-04-20 03:44 PM List items in a Combobox from ini file
kirkside Offline
Getting the hang of it

Registered: 2006-01-19
Posts: 52
Loc: UK
I want to populate a combobox based on a list of items from an ini file. Can anyone help please? I sure this is simple, but I cannot get it to work. I can get 1 item to appear easily, but not multiple.

Thank you in advance.

Top
#160950 - 2006-04-20 04:03 PM Re: List items in a Combobox from ini file
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Well,

there are plenty of samples on kixforms forums, but as always, these are very special solutions for individual needs

Show us what you have so far and tell us where you want to go with it.
I'm sure there will be a solution within the next hour
_________________________



Top
#160951 - 2006-04-20 04:04 PM Re: List items in a Combobox from ini file
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
look at GetINI() in the UDF forum
then do a for each $item in GetINI($inifile,section) $combobox.additem($item) next
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#160952 - 2006-04-21 10:23 AM Re: List items in a Combobox from ini file
kirkside Offline
Getting the hang of it

Registered: 2006-01-19
Posts: 52
Loc: UK
Firstly, as always on this site, thank you for your replies. I don't know why I don't do this in the first place, but here is exactly what I am trying to achieve.

I have built a utility for the desktop team with some useful tools. This utility will be distributed around Europe. There is a drop down box where the engineer will choose their site location, e.g. UK, Spain, Italy. Then based on the location, another drop list displays available printers. Now, I have no idea how I could get the drop down list to connect to the server and then display the printers available (if anyone knows I would be fascinated to find out how), but instead I thought i could get a list of printers from an .ini file. The engineer would then select the printer, click on a button and the printer would install. There also needs to be a line in the ini file with the install share path. There will be 3 other drop down boxes with the available printers for that site so that the engineer can install 4 printers all at once.

i hope this makes sense.

An example is below of the ini file layouts I have worked with.

ini file

[UK]
HPLJ4050
HPLJ5SI

[Italy]
HPLJ4050
HPLJ5SI

Top
#160953 - 2006-04-21 11:03 AM Re: List items in a Combobox from ini file
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
I use a bespoke printer manager for Citrix which does a similar thing.

I have two windows - the window on the left shows the users currently connected printers, the window on the right shows printers available on the print server. Double-clicking moves the printer from one side to the other. There is also a "set default printer" button.

It's a large script which is heavily biased to my environment, but you are welcome to look at it to get some ideas.

I'll stress up front though, if you have problems with it I will probably not have a lot of time to help as things are about to get very busy round here...

Top
#160954 - 2006-04-21 12:24 PM Re: List items in a Combobox from ini file
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
Well, I'd make it a step easier.

Detect their nework address/subnet and then populate the ALL the printers for that location.

All that would then need to be done manually, is choose the default.

Code:

$nic=0
:nicloop
$mygw=enumipinfo($nic,3) $ip=enumipinfo($nic,0)
select ; determine physical location of computer
Case $mygw="192.168.84.129" $Location="01"
Case $mygw="192.168.61.17" $Location="02"
Case $mygw="192.168.5.1" $Location="02"
Case $mygw="192.168.61.1" $Location="02"
Case $mygw="192.168.200.129" $Location="03"
Case $mygw="192.168.61.193" $Location="03"
Case $mygw="192.168.61.225" $Location="03"
Case $mygw="192.168.85.1" $Location="04"
Case $mygw="192.168.39.129" $Location="05"
Case $mygw="192.168.163.129" $Location="05"
Case $mygw="192.168.34.1" $Location="06"
Case $mygw="192.168.41.129" $Location="07"
Case $mygw="192.168.103.1" $Location="08"
Case $mygw="192.168.33.1" $Location="09"
Case $mygw="192.168.163.193" $Location="09"
Case $mygw="192.168.28.1" $Location="10"
Case $mygw="192.168.106.1" $Location="11"
Case $mygw="192.168.63.225" $Location="11"
if $Location = "00" and val($nic) < 10
$nic=val($nic)+1
goto nicloop
endif
if $Location = "00"
$=sendmessage("Admin","IP Detection Failed on @wksta @crlf @userid @crlf @lserver @crlf @scriptdir @crlf $mygw")
quit
endif





There may even be a WMI method of grabbing all the server's printers skipping the need for hardcode or ini's but I haven't looked for that (yet)
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#160955 - 2006-04-21 12:33 PM Re: List items in a Combobox from ini file
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
If you were going to make it that easy you'd enumerate the printers and check the IP address against your own to eliminate the need to select a location in the first place.

Or maybe you'd use the AD facility to publish the printers (no good for us on a Citrix farm though).

Quote:

There may even be a WMI method of grabbing all the server's printers skipping the need for hardcode or ini's but I haven't looked for that (yet)




Yup, that's what my printer manager does.

Top
#160956 - 2006-04-21 01:02 PM Re: List items in a Combobox from ini file
kirkside Offline
Getting the hang of it

Registered: 2006-01-19
Posts: 52
Loc: UK
You guys come up with some great ideas. I like the idea of getting the utility to detect which site the user is at. So how would I populate the drop down list with the printers from that location?

When the utility is use, it is before the computer is connected to the domain.

Below is a vbscript that i just found that tells me all of the printers on a server. It gets close for me, but still not sure how to list it, or to use kix instead. Still learning this wonderful stuff.


Code:
  Set objComputer = GetObject("WinNT://printservername,computer")
objComputer.Filter = Array("printQueue")
For Each objPrinter In objComputer
Set objPrintQueue = GetObject(objPrinter.ADsPath)
Wscript.Echo objPrintQueue.Name
Next


Top
#160957 - 2006-04-21 01:33 PM Re: List items in a Combobox from ini file
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Here's the printer manager script I use. You should be able to pick something out of it:
Code:
$=SetOption("ASCII","ON") $=SetOption("WrapAtEOL","ON") $=SetOption("Explicit","ON") Break ON
; vim: ai ts=4 sw=4 fdm=marker fdc=4:

Global $__SERVER_PRINT,$__DOMAIN_PRINT

Global $SYSTEM,$FORMS,$SPOOLERWMI,$ERROR
Global $TRUE,$FALSE

GLOBAL $oWinNT

$__DOMAIN_PRINT="***YOUR DOMAIN HERE***"
$__SERVER_PRINT="***YOUR PRINT SERVER HERE***"

$TRUE=Not 0
$FALSE=Not $TRUE

; Initialise KiXtart system
$SYSTEM=CreateObject("KiXtart.System")
If Not (9=VarType($SYSTEM)) $ERROR=@ERROR funError("Could not create KiXtart system - perhaps KiXforms is not registered?") Exit $ERROR EndIf
; Create a collection to index the forms.
$FORMS=$SYSTEM.Collection()
; Make Form
udfMakeForm("frmMain")
If @ERROR Exit @ERROR EndIf

$oWinNT=GetObject("WinNT://"+$__DOMAIN_PRINT+"/"+$__SERVER_PRINT+",computer")
If @ERROR $=funError("Cannot get printer list from "+$__DOMAIN_PRINT+"\"+$__SERVER_PRINT+@CRLF+"["+fnCOMErr(@ERROR)+"] "+@SERROR) Exit @ERROR EndIf

$FORMS.Item("frmPopup").Controls("txtPopMsg").Text="Getting list of printers - Please Wait"
$FORMS.Item("frmMain").Show
$FORMS.Item("frmPopup").ShowModal
udfLoadPrinters($FORMS.Item("frmMain").Controls("lvPtrConnected"),$FORMS.Item("frmMain").Controls("lvPtrAvailable"))
If @ERROR Exit @ERROR EndIf
$FORMS.Item("frmPopup").Hide

While $SYSTEM.ActiveForm.Visible
$=Execute($SYSTEM.ActiveForm.DoEvents())
Loop

Sleep 10

Exit 0
; Insert value *before* array element iPosition - No position=append
Function funInsertArrayElement($vaArray,$vValue,Optional $iPosition) ; {{{
Dim $iElements,$iNewElements,$iIndex

$funInsertArrayElement=$vaArray

$iElements=Ubound($vaArray)

If Not VarType($iPosition) $iPosition=$iElements+1 EndIf

If $iPosition<=$iElements $iNewElements=$iElements+1 Else $iNewElements=$iPosition EndIf

Redim Preserve $funInsertArrayElement[$iNewElements]

If $iPosition<=$iElements
For $iIndex = $iElements To $iPosition Step -1
$funInsertArrayElement[$iIndex+1]=$funInsertArrayElement[$iIndex]
Next
EndIf
$funInsertArrayElement[$iPosition]=$vValue
Exit 0
EndFunction ; }}}
; Delete value *at* array element iPosition - No position=delete last element
Function funDeleteArrayElement($vaArray,Optional $iPosition) ; {{{
Dim $iElements,$iIndex
$iElements=Ubound($vaArray)
If $iElements < 0 Exit 1629 EndIf
If Not VarType($iPosition) $iPosition=$iElements EndIf
$iPosition=CInt($iPosition)
If $iPosition < 0 OR $iPosition >$iElements $funDeleteArrayElement=$vaArray Exit 1734 EndIf
; Deleting last element - return null array
If Not $iElements Exit 0 EndIf
$funDeleteArrayElement=$vaArray
For $iIndex=$iPosition To $iElements-1
$funDeleteArrayElement[$iIndex]=$funDeleteArrayElement[$iIndex+1]
Next
Redim Preserve $funDeleteArrayElement[$iElements-1]
Exit 0
EndFunction ; }}}
; Remove repeated characters
Function udfPack($sString,Optional $sDelimiter) ; {{{
Dim $sElement
$udfPack=CStr("")
If Not VarType($sDelimiter) $sDelimiter=" " EndIf
For Each $sElement In Split($sString,$sDelimiter)
If $sElement $udfPack=$udfPack+$sDelimiter+$sElement EndIf
Next
$udfPack=SubStr($udfPack,Len($sDelimiter)+1)
Exit 0
EndFunction ; }}}
Function funError($sMessage, Optional $sTitle) ; {{{
If Not $sTitle $sTitle="Printer Management Error" EndIf
$funError=MessageBox($sMessage,$sTitle,0+48)
Exit 0
EndFunction ; }}}
Function funDispatcher($ofrmMain) ; {{{
Dim $oMonitor
; Force reset error flag
$oMonitor=Execute("Exit 0")
$oMonitor=$ofrmMain.sStatus
While @ERROR=0
$funDispatcher=$oMonitor.value
$oMonitor.value=""
If $funDispatcher Exit 0 EndIf
Sleep 0.1
$oMonitor=$ofrmMain.sStatus
Loop
Exit 1
EndFunction ; }}}
Function udfOnLostFocus($sControl) ; {{{
Dim $oControl $oControl=$SYSTEM.ActiveForm.Controls($sControl)
Select
Case "Unhandled"
"Unhandled lost focus on '"+$oControl.Name+"'"+@CRLF
EndSelect
EndFunction ; }}}
Function udfOnClick($sControl) ; {{{
Dim $oControl $oControl=$SYSTEM.ActiveForm.Controls($sControl)
Dim $oSelectedItem
Select
Case $oControl.Name="btnRefresh"
$FORMS.Item("frmPopup").Controls("txtPopMsg").Text="Getting list of printers - Please Wait"
$FORMS.Item("frmPopup").ShowModal
udfLoadPrinters($FORMS.Item("frmMain").Controls("lvPtrConnected"),$FORMS.Item("frmMain").Controls("lvPtrAvailable"))
If @ERROR Quit @ERROR EndIf
$FORMS.Item("frmPopup").Hide
Case $oControl.Name="btnExit"
$SYSTEM=0
Quit 0
Case $oControl.Name="btnSetDefault"
$oSelectedItem=$FORMS.Item("frmMain").Controls("lvPtrConnected").FocusedItem
$FORMS.Item("frmPopup").Controls("txtPopMsg").Text="Setting '"+$oSelectedItem.Subitems(0).Text+"' as default"+@CRLF+"Please wait"
$FORMS.Item("frmPopup").ShowModal
"Default requested 0 : " $oSelectedItem.SubItems(0).Text ?
"Default requested 1 : " $oSelectedItem.SubItems(1).Text ?
"Default requested 2 : " $oSelectedItem.SubItems(2).Text ?
"Default requested 3 : " $oSelectedItem.SubItems(3).Text ?
If SetDefaultPrinter($oSelectedItem.SubItems(2).Text)
If SetDefaultPrinter($oSelectedItem.SubItems(2).Text+": "+$oSelectedItem.SubItems(1).Text)
$FORMS.Item("frmPopup").Controls("txtPopMsg").Text="Could not set printer '"+$oSelectedItem.Subitems(0).Text+"' as default"+@CRLF
+"Error ["+@ERROR+"] "+@SERROR
Sleep 5
EndIf
EndIf
$FORMS.Item("frmPopup").Hide
udfShowDefault()
udfTickDefault()
Case $oControl.Name="btnImage"
$FORMS.Item("frmMain").Controls("lvPtrConnected").Items(0).ImageIndex=1+$FORMS.Item("frmMain").Controls("lvPtrConnected").Items(0).ImageIndex
$FORMS.Item("frmMain").Controls("lvPtrConnected").Items(0).SubItems(1).Text=$FORMS.Item("frmMain").Controls("lvPtrConnected").Items(0).ImageIndex
Case "Unhandled"
"Unhandled click on '"+$oControl.Name+"'"+@CRLF
EndSelect
EndFunction ; }}}
Function udfOnDoubleClick($sControl) ; {{{
Dim $oControl $oControl=$SYSTEM.ActiveForm.Controls($sControl)
Dim $oNewItem
Dim $oSelectedItem
Select
Case $oControl.Name="lvPtrConnected"
$oSelectedItem=$oControl.FocusedItem
If VarType($oSelectedItem) AND $oSelectedItem.Selected
"Selected Item=" $oSelectedItem.Subitems(0).Text @CRLF
$FORMS.Item("frmPopup").Controls("txtPopMsg").Text="Trying to disconnect printer '"+$oSelectedItem.Subitems(0).Text+"'"+@CRLF+"Please wait"
$FORMS.Item("frmPopup").ShowModal
If DelPrinterConnection($oSelectedItem.SubItems(2).Text)
$FORMS.Item("frmPopup").Controls("txtPopMsg").Text="Could not disconnect printer '"+$oSelectedItem.Subitems(0).Text+"'"+@CRLF
+"Error ["+@ERROR+"] "+@SERROR
Sleep 5
Else
$oNewItem=$FORMS.Item("frmMain").Controls("lvPtrAvailable").Items.Add
$oNewItem.SubItems(0).Text=$oSelectedItem.SubItems(0).Text
$oNewItem.SubItems(1).Text=$oSelectedItem.SubItems(1).Text
$oNewItem.SubItems(2).Text=$oSelectedItem.SubItems(2).Text
$oControl.Items.Remove($oSelectedItem.Index)
$FORMS.Item("frmMain").Controls("lvPtrAvailable").Sorted=$FALSE
$FORMS.Item("frmMain").Controls("lvPtrAvailable").Sorted=$TRUE
udfTickDefault()
udfShowDefault()
EndIf
$FORMS.Item("frmPopup").Hide
EndIf
Case $oControl.Name="lvPtrAvailable"
$oSelectedItem=$oControl.FocusedItem
If VarType($oSelectedItem) AND $oSelectedItem.Selected
"Selected Item=" $oSelectedItem.Subitems(0).Text @CRLF
$FORMS.Item("frmPopup").Controls("txtPopMsg").Text="Trying to connect printer '"+$oSelectedItem.Subitems(0).Text+"'"+@CRLF+"Please wait"
$FORMS.Item("frmPopup").ShowModal
If AddPrinterConnection($oSelectedItem.SubItems(2).Text)
$FORMS.Item("frmPopup").Controls("txtPopMsg").Text="Could not disconnect printer '"+$oSelectedItem.Subitems(0).Text+"'"+@CRLF
+"Error ["+@ERROR+"] "+@SERROR
Sleep 5
Else
$oNewItem=$FORMS.Item("frmMain").Controls("lvPtrConnected").Items.Add
$oNewItem.SubItems(0).Text=$oSelectedItem.SubItems(0).Text
$oNewItem.SubItems(1).Text=$oSelectedItem.SubItems(1).Text
$oNewItem.SubItems(2).Text=$oSelectedItem.SubItems(2).Text
$oControl.Items.Remove($oSelectedItem.Index)
$FORMS.Item("frmMain").Controls("lvPtrConnected").Sorted=$FALSE
$FORMS.Item("frmMain").Controls("lvPtrConnected").Sorted=$TRUE
udfTickDefault()
udfShowDefault()
EndIf
$FORMS.Item("frmPopup").Hide
EndIf
Case "Unhandled"
"Unhandled double click on '"+$oControl.Name+"'"+@CRLF
EndSelect
EndFunction ; }}}
Function udfMakeForm($n) ; {{{
Dim $ERROR,$oControl,$f,$,$i,$oToolTip
Select
Case $n="frmMain"
$oToolTip=$SYSTEM.ToolTip()

$f=$SYSTEM.Form()
If Not (9=VarType($f)) $ERROR=@ERROR funError("Could not create new form - perhaps KiXforms is not registered?") Exit $ERROR EndIf
$f.Name=$n
$FORMS.Add($f,$f.Name)
$f.Caption="MSV-SGB Printer Manager"
$f.Width=690
$f.Height=335
$f.Center

$oControl=$f.Controls.Label("Your printers",10,10,260,15)

$oControl=$f.Controls.Listview("lvPtrConnected",10,30,335,235)
$oControl.Name="lvPtrConnected"
$oControl.MultiSelect=$FALSE
$oControl.View=1
$oControl.SmallImageList=$SYSTEM.BuiltinImageList
$oControl.Sorted=$TRUE
$oControl.OnDoubleClick="udfOnDoubleClick('"+$oControl.Name+"')"
$oControl.OnClick="udfShowDefault('"+$oControl.Name+"')"
$oToolTip.SetToolTip($oControl,"Double click on a printer to disconnect it")
$=$oControl.Columns.Add("Name",130,0)
$=$oControl.Columns.Add("Description",200,0)
$=$oControl.Columns.Add("Share Name",0,0)
$=$oControl.Columns.Add("Print Device",0,0)

$oControl=$f.Controls.Label("Available printers",355,10,260,15)

$oControl=$f.Controls.Listview("lvPtrAvailable",355,30,315,235)
$oControl.Name="lvPtrAvailable"
$oControl.Sorted=$TRUE
$oControl.OnDoubleClick="udfOnDoubleClick('"+$oControl.Name+"')"
$oToolTip.SetToolTip($oControl,"Double click on a printer to connect it")
$=$oControl.Columns.Add("Name",110,0)
$=$oControl.Columns.Add("Description",200,0)
$=$oControl.Columns.Add("Share Name",0,0)
$=$oControl.Columns.Add("Print Device",0,0)

$oControl=$f.Controls.Button("Set As Default",20,270,100,25)
$oControl.Name="btnSetDefault"
$oControl.OnClick="udfOnClick('"+$oControl.Name+"')"
$oControl.Hide()

$oControl=$f.Controls.Button("Refresh List",545,270,75,25)
$oControl.Name="btnRefresh"
$oControl.OnClick="udfOnClick('"+$oControl.Name+"')"

$oControl=$f.Controls.Button("Exit",625,270,45,25)
$oControl.Name="btnExit"
$oControl.OnClick="udfOnClick('"+$oControl.Name+"')"

$f=$SYSTEM.Form($f)
$FORMS.Add($f,"frmPopup")
$f.Caption="Message"
$f.ControlBox=$FALSE
$f.FormBorderStyle=5
$f.Width=300
$f.Height=150

$oControl=$f.Controls.Label("Message Text",5,5,290,140)
$oControl.Name="txtPopMsg"
$oControl.ContentAlignment=32
EndSelect
Exit 0
EndFunction ; }}}
Function udfLoadPrinters($oPtrConnected,$oPtrAvailable) ; {{{
Dim $oPrintQueue,$oNewItem,$asConnected[3],$oNetwork,$oPrinters,$sPrinterInfo
Dim $i,$asTemp

; Delete all existing items from listview
While $oPtrConnected.Items.Count $oPtrConnected.Items.Remove(0) Loop
While $oPtrAvailable.Items.Count $oPtrAvailable.Items.Remove(0) Loop

; Cache existing connections
$oNetwork=CreateObject("WScript.Network")
If Not 9=VarType($oNetwork) funError("Cannot create network object"+@CRLF+"["+@ERROR+"] "+@SERROR+@CRLF) Exit @ERROR EndIf
$oPrinters=$oNetwork.EnumPrinterConnections()
For $i=0 To $oPrinters.Count-1 Step 2
$asTemp=$asConnected[0]
Redim Preserve $asTemp[Ubound($asTemp)+1]
$asTemp[UBound($asTemp)]=$oPrinters.Item($i+1)
If InStr($asTemp[UBound($asTemp)],":") $asTemp[UBound($asTemp)]=Left($asTemp[UBound($asTemp)],InStr($asTemp[UBound($asTemp)],":")-1) EndIf
$asConnected[0]=$asTemp
$asTemp=$asConnected[1]
Redim Preserve $asTemp[Ubound($asTemp)+1]
$asTemp[UBound($asTemp)]=$oPrinters.Item($i)
$asConnected[1]=$asTemp
Next

$oWinNT.Filter = "PrintQueue",""

; Add all printers - already mapped printers to "connected" otherwise to "available"
For Each $oPrintQueue In $oWinNT
$i=AScan($asConnected[0],$oPrintQueue.PrinterPath)
If 1+$i
$oNewItem=$oPtrConnected.Items.Add
Else
$oNewItem=$oPtrAvailable.Items.Add
EndIf
$oNewItem.SubItems(0).Text=$oPrintQueue.Name
$oNewItem.SubItems(1).Text=$oPrintQueue.Description
$oNewItem.SubItems(2).Text=$oPrintQueue.PrinterPath
$oNewItem.SubItems(3).Text=$oPrintQueue.PrintDevices
Next

udfTickDefault()
udfShowDefault()

Exit 0
EndFunction ; }}}
Function udfTickDefault() ; {{{
Dim $sDefaultPath,$oItem
$sDefaultPath=Split(ReadValue("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device"),",")[0]
For Each $oItem in $FORMS.Item("frmMain").Controls("lvPtrConnected").Items
If $oItem.SubItems(2).Text=$sDefaultPath OR $oItem.SubItems(2).Text+": "+$oItem.SubItems(1).Text=$sDefaultPath
$oItem.ImageIndex=10
Else
$oItem.ImageIndex=66
EndIf
Next
EndFunction ; }}}
Function udfShowDefault(Optional $x) ; {{{
Dim $oControl $oControl=$SYSTEM.ActiveForm.Controls("lvPtrConnected")
Dim $oSelectedItem $oSelectedItem=$oControl.FocusedItem
If VarType($oSelectedItem) AND $oSelectedItem.Selected
If $oSelectedItem.ImageIndex=10
$FORMS.Item("frmMain").Controls("btnSetDefault").Hide()
Else
$FORMS.Item("frmMain").Controls("btnSetDefault").Show()
EndIf
EndIf
EndFunction ; }}}
Function fnCOMErr($lErr) ; {{{
If $lErr<0 $lErr=VAL("&"+Right(DecToHex($lErr),4)) EndIf
$fnCOMErr=$lErr
Exit $lErr
Endfunction ; }}}


Top
#160958 - 2006-04-21 04:36 PM Re: List items in a Combobox from ini file
kirkside Offline
Getting the hang of it

Registered: 2006-01-19
Posts: 52
Loc: UK
Thank you Richard for you script. Below is the function that I am now using taken from it. I am now able to populate the drop lists based on the site and then after clicking on a button the printers both install. Excellent. Now, I have a problem. When the script runs in the live environment, it runs on a pc that is not on the Domain yet. Therefore, i get an access denied when it comes to getting the printers list. Now in the utility I have created, the engineer puts in his account details before putting the computer on the domain. Is there anyway, to get the below function to use these credentials?

Code:
Function ShowPrinters()

$Printer1.clear
$Printer2.clear

Global $__SERVER_PRINT,$__DOMAIN_PRINT

GLOBAL $oWinNT

$SitePrinter = readprofilestring("C:\Store\ADScript\sites.ini",$OU.Text,"PrinterPath")

$__DOMAIN_PRINT="MyDomain"
$__SERVER_PRINT=$SitePrinter

$oWinNT=GetObject("WinNT://"+$__DOMAIN_PRINT+"/"+$__SERVER_PRINT+",computer")

$oWinNT.Filter = "PrintQueue",""

; Add all printers - already mapped printers to "connected" otherwise to "available"
For Each $oPrintQueue In $oWinNT
$Printer1.additem($oPrintQueue.Name)
$Printer2.additem($oPrintQueue.Name)
Next

EndFunction


Top
#160959 - 2006-04-21 04:44 PM Re: List items in a Combobox from ini file
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Have you tried connecting to the IPC$ share?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#160960 - 2006-04-21 05:59 PM Re: List items in a Combobox from ini file
kirkside Offline
Getting the hang of it

Registered: 2006-01-19
Posts: 52
Loc: UK
mmm, do you mean for instance

net use \\server\IPC$ /user:domain\$ITStaffName $ITPassword

would I do that in the function just before the GetObject part?

Top
#160961 - 2006-04-21 06:14 PM Re: List items in a Combobox from ini file
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I would do it before the function is called.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#160962 - 2006-04-21 07:30 PM Re: List items in a Combobox from ini file
kirkside Offline
Getting the hang of it

Registered: 2006-01-19
Posts: 52
Loc: UK
Excellent. Thank you Les. I will give that a go when I get a chance later.
Top
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 657 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.242 seconds in which 0.179 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org