Page 1 of 1 1
Topic Options
#145080 - 2005-08-09 03:26 PM Using EnumIPInfo to map printers
abuthemagician Offline
Fresh Scripter

Registered: 2005-08-09
Posts: 5
We use roaming profiles, and my tellers move between branches a lot. Depending on which branch they are in determines what network printer should be their default. Right now i am using a couple of "if ingroup()" statements to get er done, but this requires me to change their AD profile before they login. I want to use EnumIPInfo to get their default gateway, then map and set the default printer based on that. Will this code do it?
Code:
 
if ingroup(Print_Teller)
if EnumIPInfo(0,3,1) = 192.168.1.1
if AddPrinterConnection ("\\server1\HP_2200_Printer1") = 0
? "Added printer connection...."
endif
if SetDefaultPrinter ("\\server1\HP_2200_Printer1")
? "Set default printer to HP_2200_Printer1..."
endif
endif
if EnumIPInfo(0,3,1) = 192.168.1.2
if AddPrinterConnection ("\\server2\HP_2200_Printer2") = 0
? "Added printer connection...."
endif
if SetDefaultPrinter ("\\server2\HP_2200_Printer2")
? "Set default printer to HP_2200_Printer2..."
endif
endif
if EnumIPInfo(0,3,1) = 192.168.1.3
if AddPrinterConnection ("\\server3\HP_2200_Printer3") = 0
? "Added printer connection...."
endif
if SetDefaultPrinter ("\\server3\HP_2200_Printer3")
? "Set default printer to HP_2200_Printer3..."
endif
endif
endif


Top
#145081 - 2005-08-09 04:33 PM Re: Using EnumIPInfo to map printers
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Yes it will work, but you should enclose the group name and IP addresses in speech marks (they are strings) and as they are mutually exclusive you should used "CASE / SELECT" rather than a lot of "IF /ENDIFS" - it will be neater and less prone to coding errors.

You should also cater for multi-adaptor scenarios unless you can guarantee that there will only ever be one.

You might also want to include some error checking.

Finally, you may want to use an INI file as a cross reference for the site / printer selection. This will save you having to edit the script for additions and changes.


Edited by Richard H. (2005-08-09 04:36 PM)

Top
Page 1 of 1 1


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

Who's Online
0 registered and 484 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.049 seconds in which 0.026 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