Page 1 of 1 1
Topic Options
#147627 - 2005-09-12 10:36 PM Add a printer based on group and Default gateway
abuthemagician Offline
Fresh Scripter

Registered: 2005-08-09
Posts: 5
Here is what i want to do:

if ingroup("Marketing")
if(Default gateway = x.x.x.1)
if AddPrinterConnection ("\\server1\HP_2200_1") = 0
? "Added printer connection...."
Endif
Endif
if(Default gateway = x.x.x.2)
if AddPrinterConnection ("\\server2\HP_2200_2") = 0
? "Added printer connection...."
Endif
Endif
if(Default gateway = x.x.x.3)
if AddPrinterConnection ("\\Server3\HP_2200_3") = 0
? "Added printer connection...."
Endif
Endif
Endif


Is this possible and what do i use to get the default gateway?

Top
#147628 - 2005-09-12 10:44 PM Re: Add a printer based on group and Default gateway
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
A quick search using the two words DEFAULT GATEWAY should give you at least three hits in the UDF section.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#147629 - 2005-09-12 10:46 PM Re: Add a printer based on group and Default gateway
abuthemagician Offline
Fresh Scripter

Registered: 2005-08-09
Posts: 5
Thanks
Top
#147630 - 2005-09-13 05:04 AM Re: Add a printer based on group and Default gateway
Skip Offline
Fresh Scripter

Registered: 2005-07-01
Posts: 41
Search the UDF section for the word "Group" sealeopard helped me out with this same problem a few months ago, and the solution works great.
_________________________
-sphilip

Top
#147631 - 2005-09-13 05:24 AM Re: Add a printer based on group and Default gateway
Skip Offline
Fresh Scripter

Registered: 2005-07-01
Posts: 41
Here is the examples I am using. It first checks the group information, then the default printer. If it does not have the correct default printer, it installs the appropriate one, and a secondary printer based on the group the PC is in. If it has the correct default printer it exits, without connecting \ installing the printer again.

Code:

If fnADComputerInGroup('GROUPNAME')=1
If $DefaultPrinter = "\\SERVER\HP LaserJet 4000 Series PCL 6 #2 on SERVER"
RETURN
ELSE
AddPrinterConnection("\\SERVER\hp4000-2")
AddPrinterConnection("\\SERVER\copier1")
? "Added printer connection...."
If SetDefaultPrinter("\\SERVER\HP LaserJet 4000 Series PCL 6 #2 on SERVER") = 0
? "Default printer was set to \\SERVER\hp4000-2, by the Kitchen Area in BLDG 1"
RETURN
EndIf
EndIf
EndIf



UDF CODE, SEALEOPARD CREATED THIS. THEN POSTED NEWER CODE, BUT THIS WORKED FOR ME SO I KEPT IT.

Code:

fnADComputerInGroup("TestGroup")

Function fnADComputerInGroup($sGroupDN)
Dim $objSys,$objCom,$aMemberOf,$sMemberOf
$objSys = CreateObject("ADSystemInfo")
$objCom = GetObject("LDAP://"+$objSys.ComputerName)
$aMemberOf = $objCom.GetEx("memberOf")
For Each $sMemberOf in $aMemberOf
If InStr($sMemberOf,"CN="+$sGroupDN+",")
$fnADComputerInGroup = NOT 0
Exit
EndIf
Next
$fnADComputerInGroup = NOT 1
EndFunction

_________________________
-sphilip

Top
#147632 - 2005-09-13 05:29 AM Re: Add a printer based on group and Default gateway
Skip Offline
Fresh Scripter

Registered: 2005-07-01
Posts: 41
OOPS, soorry!! Here is the defualt printer stuff. Place this in your script prior to mappings. this was also found in this forum somewhere, posted by some genius.

Good Luck!!

Code:
 
;Find out what the Default Printer is
$PrinterKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows"
$PrinterVal = "Device"
$TempString = READVALUE ($PrinterKey, $PrinterVal)

;The Printername is the first part of the registry value
$x = INSTR($TempString,",")
$DefaultPrinter = SUBSTR($TempString,1,$x-1)


_________________________
-sphilip

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 194 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.146 seconds in which 0.105 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