#80461 - 2001-11-07 08:42 PM
Network Printer Connection
|
Anonymous
Anonymous
Unregistered
|
Does anyone have a good script they used to add network printer connections? Also, when network printer connections are added how do you also add the correct drivers?
|
|
Top
|
|
|
|
#80462 - 2001-11-08 11:39 AM
Re: Network Printer Connection
|
thyssen
Lurker
Registered: 2001-10-30
Posts: 2
Loc: UK
|
HelloI have written a script for printer connections to for each of my branches, they enter the branch they are at, this shows a list of available printers where they choose the default printet and all the available printer connections are added. e-mail me at gary.cleasby@thyssen.co.uk and I will send it to you Regards
_________________________
Gary Cleasby
Infrastructure Support
ThyssenKrupp Materials (UK) Ltd
gary.cleasby@thyssen.co.uk
|
|
Top
|
|
|
|
#80463 - 2001-11-09 12:45 AM
Re: Network Printer Connection
|
Anonymous
Anonymous
Unregistered
|
Gary, Could you please post your script on the board?
Thanks,
|
|
Top
|
|
|
|
#80465 - 2001-11-16 06:24 AM
Re: Network Printer Connection
|
MCA
KiX Supporter
   
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
Input from Chris PageNot sure if this is a "good solution" but it's been in use for some years, still untidy code I'm afraid. HTH. Our solution uses Con2Prt.exe from the reskit. Drivers are auto-installed if necessary. We call SetUpPrinters in the Login script. The [Local Printers] section is written by the Audit code which uses WMI to read the current printers as follows: code:
;Printers (Local) $I = 1 WriteProfileString("Y:\@WKSTA\Status.ini","System","Printers", "Status, Name, Location, Default, Shared, Network, Local, Driver, Port, Server, Share, DeviceID") $Collection = GetObject("winmgmts:").InstancesOf("Win32_Printer") WriteStatus("") For each $Item in $Collection $Data = "" + $Item.Status + ", " + $Item.Name + ", " + $Item.Location + ", " + FormatAttr($Item.Attributes) ;commer added by routine $Data = $Data + $Item.DriverName + ", " + $Item.PortName + ", " + $Item.ServerName + ", " + $Item.ShareName + ", " + $Item.DeviceID WriteProfileString("Y:\@WKSTA\Status.ini","System","Printer" + $I, $Data) If ($Item.Attributes & 64) And (InStr($Item.PortName, "\\") = 0) ;Local Printer $Data = "" + $Item.Name + ", Driver: " + $Item.DriverName If ($Item.Attributes & 8) $Data = $Data + ", Shared as: " + $Item.ShareName endif WriteProfileString("Y:\Stations.ini","Local Printers",@WKSTA, $Data + " LOCATION: " + $Item.Location) WriteStatus("Local Printer: " + $Item.Name) WriteStatus(" Driver: " + $Item.DriverName) WriteStatus(" Shared as: " + $Item.ShareName) endif If $Item.Attributes & 4 ;Default Printer $Data = "" + $Item.Name + ", Driver: " + $Item.DriverName If ($Item.Attributes & 64) And (InStr($Item.PortName, "\\") = 0) $Data = "LOCAL: " + $Data endif WriteProfileString("Y:\Status.ini","Default Printers",@WKSTA, $Data) WriteStatus("Default Printer: " + $Item.Name) WriteStatus(" Driver: " + $Item.DriverName) WriteStatus(" Location: " + $Item.Location) endif $I = $I + 1 Next
We creates an outline of the INI file and the Station's directory if it doesn't exist thus: code:
if Exist("Y:\@WKSTA")=0 MD "Y:\@WKSTA" endif $ret = WriteProfileString("Y:\Stations.ini","Kixtart","Version","$Ver") $ret = $ret + WriteProfileString("Y:\Stations.ini","Kixtart","PDC","$PDC") $ret = $ret + WriteProfileString("Y:\Stations.ini","Kixtart","BDC","$BDC") $ret = $ret + WriteProfileString("Y:\Stations.ini","Kixtart","CDServer","$CDServer") $ret = $ret + WriteProfileString("Y:\Stations.ini","Kixtart","KIX Version","@KIX") ;create List of Stations and outline of file $ret = $ret + WriteProfileString("Y:\Stations.ini","Additional Printers","Printer1-5","\\NameOfComputerWithPrinterAttached\ShareName") $ret = $ret + WriteProfileString("Y:\Stations.ini","Printers","ComputerName","\\NameOfComputerWithPrinterAttached\ShareName") $ret = $ret + WriteProfileString("Y:\Stations.ini","Stations",@WKSTA,"@Userid at @Time on @Day @MDAYNO @Month @Year @ProductType Ver.@DOS Build @Build @CSD") $ret = $ret + WriteProfileString("Y:\@WKSTA\Station.ini","Additional Printers","Printer1-5","\\NameOfComputerWithPrinterAttached\ShareName") $ret = $ret + WriteProfileString("Y:\@WKSTA\Status.ini","System","OS","@ProductType Ver @DOS Build @Build @CSD") if $ret <> 0 color r/n ? "WARNING: Update Stations.ini errors: $ret, @Error" color w/n endif
[ 16 November 2001: Message edited by: MCA ]
|
|
Top
|
|
|
|
#80466 - 2001-11-16 06:36 AM
Re: Network Printer Connection
|
MCA
KiX Supporter
   
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
input from Chris Page (second part):Then these are the UDF's in use. (Revised for 4.0, tested on NT4 & XP.) code:
Function SetupPrinters ; Uses Y:\Stations.ini and Y:\@Wksta\Station.ini to setup printers ; NT/W2K/XP only ; Y:\Stations.ini (Printers) has a default printer for each station without a local one ; Y:\Stations.ini (Additional Printers) has global additional printers ; Y:\@Wksta\Station.ini (Additional Printers) has additional printers just for that station. $P=1 ? "Printers..." ? SHELL "P:\Con2Prt /f" ;clear any existing in profile ; Global additional printers Do $Printer = ReadProfileString("Y:\Stations.ini","Additional Printers","Printer" + $P) if $Printer <> "" PrintLog(" Connecting: " + "P:\Con2Prt /c " + $Printer,1) SHELL "P:\Con2Prt /c " + $Printer else $P = 5 ;no more so exit loop endif $P=$P+1 Until $P = 6 ;Station's additional printers $P=1 Do $Printer = ReadProfileString("Y:\@wksta\Station.ini","Additional Printers","Printer" + $P) if $Printer <> "" PrintLog(" Connecting: " + "P:\Con2Prt /c " + $Printer,1) SHELL "P:\Con2Prt /c " + $Printer else $P = 5 ;no more so exit loop endif $P=$P+1 Until $P = 6 ; set default printer $Printer = ReadProfileString("Y:\Stations.ini","Printers",@WKSTA) if $Printer = "" OR $Printer = "NONE" OR $Printer = "Local" $Printer = ReadProfileString("Y:\Stations.ini","Local Printers",@WKSTA) If $Printer = "" Return else $Printer = SubStr($Printer,1,InStr($Printer,",")-1) endif if SetDefaultPrinter("$Printer")=0 ? PrintLog("Setting Default Printer to $Printer") else PrintLog("No Network Printer set for this station",1) if INGROUP("Domain Admins") ;fix it ;Create entry ready to be completed WriteProfileString("Y:\Stations.ini","Printers",@WKSTA,"NONE") SelectPrinter endif endif else PrintLog("Default: " + "P:\Con2Prt /cd " + $Printer,1) SHELL "P:\Con2Prt /cd " + $Printer endif EndFunction
[ 16 November 2001: Message edited by: MCA ]
|
|
Top
|
|
|
|
#80468 - 2001-11-16 06:56 AM
Re: Network Printer Connection
|
MCA
KiX Supporter
   
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
input from Chris Page (fourth/last part)code:
Function GetPrinters ; Builds a list of printers referred to in Stations.ini DIM $List, $I, $Prn, $PrnList $List = ReadProfileString("Y:\Stations.ini", "Printers", "") $WksPrnArray = Split($List,CHR(10)) For $I = 0 To UBound($WksPrnArray) - 1 ;there is a trailing CHR(10), hence a null element $Prn = ReadProfileString("Y:\Stations.ini", "Printers", $WksPrnArray[$I]) If Len($Prn) > 4 ; \\s\p is minimum valid form SELECT CASE $Prn = "\\NameOfComputerWithPrinterAttached\ShareName"; ignore this example line CASE $PrnList = "" ; first one $PrnList = $PrnList + $Prn CASE Instr($PrnList, $Prn) = 0 ; not found before $PrnList = $PrnList + "," + $Prn ENDSELECT endif Next $Printers = Split($PrnList, ",") EndFunction
Function Example_INI_files ;Example Stations.ini ;-------------------- [Kixtart] Version=6.44 PDC=\\Wig BDC=\\Wig CDServer=\\Wig KIX Version=4.00 Debug=1 ;Pause=Always [Additional Printers] Printer1-5=\\NameOfComputerWithPrinterAttached\ShareName Printer1=\\Wig\Colour [Printers] ComputerName=\\NameOfComputerWithPrinterAttached\ShareName WIG=\\wig\hplaser DFFMF60J=\\wig\hplaser D1FMF60J=\\wig\hplaser ED-BX5640J=Local DIFMF60J=NONE ;Example Station.ini for ED-BX5640J ;---------------------------------- [Additional Printers] Printer1-5=\\NameOfComputerWithPrinterAttached\ShareName Printer1=\\Wig\hplaser EndFunction Sorry if I've missed anything vital. Chris [ 16 November 2001: Message edited by: MCA ]
|
|
Top
|
|
|
|
Moderator: Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart
|
0 registered
and 1045 anonymous users online.
|
|
|