#165627 - 2006-08-09 09:32 PM
Re: Install Printers by Computer Names
|
Witto
MM club member
   
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
|
Problem is you can have two or three NIC Code:
Dim $NIC, $IPAddress $NIC = 0 While EnumIPInfo($NIC,0,0) $IPAddress = EnumIPInfo($NIC,0,0) ; Install Printers $NIC = $NIC + 1 Loop
I want to recommend the IsInSubnet UDF to find in which network the workstation is (Thanks Jens "Sealeopard") Code:
Select Case IsInSubnet($IPAddress, '192.168.35.0', '255.255.255.0') ; Do something with printers Case IsInSubnet($IPAddress, '192.168.36.0', '255.255.255.0') ; Do something with printers Case 1 ; Maybe something else EndSelect
For Citrix or Terminal Server, I want to recommend wtsmanager.dll See http://www.kixhelp.com/downloads.htm, the simple COM-wrapper for Terminal Services Manager Code:
If @TSSESSION $oWts = CreateObject("WTSManager.Shell") $IPAddress = $oWts.MyIPAddress If $IPAddress = "" ; Most probably WTSManager.dll is not registered on this terminal server Exit 0 EndIf ; Do stuff with printers EndIf
I hope this helps. I am interested in your solution to install printers for your users.
Edited by Witto (2006-08-09 10:32 PM)
|
|
Top
|
|
|
|
#165628 - 2006-08-09 10:39 PM
Re: Install Printers by Computer Names
|
hieucao
Fresh Scripter
Registered: 2006-08-09
Posts: 18
|
Gargoyle - your script worked great, but if I use it more than once in the login script, it installs all printers regardless which subnet the ws is logging in from...what gives? I've multiple subnets across the network and the print server is centralized in one subnet...
|
|
Top
|
|
|
|
#165630 - 2006-08-09 10:53 PM
Re: Install Printers by Computer Names
|
hieucao
Fresh Scripter
Registered: 2006-08-09
Posts: 18
|
Mart - here's the script that I am testing. Code:
:Domain_Users ; Generic drives for all users $section=$section+1 If InGroup ("Domain Users") CLS AT (10,25) "Mapping Drives...Please Wait" use I: "\\PPFS\%username%" use Q: "\\hpserver\hpwin" EndIf
; Installing printers by workstation name worked great. The same printer was ; also installed in Citrix
;If Not @TSSESSION ; Citrix to use Workstation name ; $ComputerName = @WKSTA ;Else ; $ComputerName = %CLIENTNAME% ;EndIf
;Select ;Case Left($ComputerName,4) = "MVIT" ; Install printers by workstation name ; $ = AddPrinterConnection("\\sharepoint\2FLX4500PS")
;EndSelect
; Testing Printer mappings depending on subnet ; Print server is on subnet 24 ; All printers get installed regardless which subnet the workstation is logging in from.
If instr(192.168.24.0, $255.255.255.0) $ = AddPrinterConnection("\\sharepoint\2FLX8550") EndIf
If instr(192.168.26.0, $255.255.255.0) $ = AddPrinterConnection("\\sharepoint\2FLX4500PS") EndIf
Thanks for everyone's input!
Edited by NTDOC (2006-08-09 11:01 PM)
|
|
Top
|
|
|
|
#165631 - 2006-08-09 11:00 PM
Re: Install Printers by Computer Names
|
Witto
MM club member
   
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
|
Code:
If instr(@IPADDRESS, "192.168.24.") ; Do stuff EndIf
|
|
Top
|
|
|
|
#165635 - 2006-08-09 11:28 PM
Re: Install Printers by Computer Names
|
Witto
MM club member
   
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
|
I presume if you are in a different subnet you would want PrinterB or PrinterC Code:
Select Case instr(@IPADDRESS, "192.168.24.") $ = AddPrinterConnection("\\Server\PrinterA") Case instr(@IPADDRESS, "192.168.25.") $ = AddPrinterConnection("\\Server\PrinterB") Case instr(@IPADDRESS, "192.168.26.") $ = AddPrinterConnection("\\Server\PrinterC") Case 1 ; Something Else EndIf
And what if you have a fixed and a wireless NIC in your portable...
|
|
Top
|
|
|
|
#165636 - 2006-08-09 11:44 PM
Re: Install Printers by Computer Names
|
Gargoyle
MM club member
   
Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
|
Uhm Witto....
Select .... EndIf ?
|
|
Top
|
|
|
|
#165637 - 2006-08-09 11:47 PM
Re: Install Printers by Computer Names
|
Gargoyle
MM club member
   
Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
|
hieucao : From the manual - Quote:
InStr( )
Action: Scans a string (from left to right) for the presence of a second string. Syntax: INSTR ("string1", "string2") Parameters: String1
The string to search in.
String2
The string to search for. Returns: ? Offset of the first character of string2 found in string1 0 String2 not present in string1
|
|
Top
|
|
|
|
#165638 - 2006-08-10 12:08 AM
Re: Install Printers by Computer Names
|
Witto
MM club member
   
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
|
Whoops, EndSelect I think @IPADDRESS does not exist. Make it @IPADDRESS0 or @IPADDRESS1 or @IPADDRESS2 But again, what if you have 2 or 3 or more NICs in your computer (fixed, wireless, other), what will @IPADDRESSx return, and @IPADDRESS just goes from 0 to 2 I would prefer to loop all NICs with EnumIPInfo. I also think my lookup is wrong as @IPADDRESS0 returns something like "192.168. 1. 5" Code:
instr(@IPADDRESS0, "192.168. 24.")
Edited by Witto (2006-08-10 12:16 AM)
|
|
Top
|
|
|
|
#165641 - 2006-08-10 12:35 AM
Re: Install Printers by Computer Names
|
hieucao
Fresh Scripter
Registered: 2006-08-09
Posts: 18
|
thanks all for providing the feedback. I'll re-read the manual and try all of your suggestions! You guys are awesome! Thanks!
|
|
Top
|
|
|
|
#165642 - 2006-08-10 02:04 AM
Re: Install Printers by Computer Names
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11628
Loc: CA
|
Removes the blank spaces in the IP Address
Code:
Dim $IP $IP = Join(Split(@IPADDRESS0," "),'') If Instr($IP,'192.168.24.')
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 1172 anonymous users online.
|
|
|