Page 1 of 1 1
Topic Options
#80461 - 2001-11-07 08:42 PM Network Printer Connection
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 Offline
Lurker

Registered: 2001-10-30
Posts: 2
Loc: UK
Hello

I 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
Unregistered


Gary,


Could you please post your script on the board?

Thanks,

Top
#80464 - 2001-11-16 06:17 AM Re: Network Printer Connection
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

We receive an email from Chris Page, which can't put following information on the board.
greetings.

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#80465 - 2001-11-16 06:24 AM Re: Network Printer Connection
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Input from Chris Page

Not 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 ]

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#80466 - 2001-11-16 06:36 AM Re: Network Printer Connection
MCA Offline
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 ]

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#80467 - 2001-11-16 06:54 AM Re: Network Printer Connection
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
input from Chris Page (third part)


Function SelectPrinter
; Offers user a selection of printers used on the network
; Allows to choose one or open Stations.ini for more complex editing
DIM $I, $s, $nul
$CurrentPrn = ReadProfileString("Y:\Stations.ini", "Printers", @WKSTA)
If $CurrentPrn = "" $CurrentPrn = "None" endif

GetPrinters ;? $PrnList

? " Workstation: " @WKSTA
? "Current Printer: " $CurrentPrn
?
? "Available Printers"
? "=================="
? "0 - Don't change."

$I = 1
For Each $Printer in $Printers
? "" + $I + " - " $Printer
$I = $I + 1
Next
? ? "Select the printer for this computer: "
DO GetS $s UNTIL Val($s) < Val($I)
SELECT
CASE Val($s) = 0 ; No Change
? "Printer not changed, @WKSTA=$CurrentPrn"
CASE Val($s) < 0 ; Prompt to enter
Run "Notepad.exe Y:\Stations.ini"
CASE 1 ; All other cases
$nul = WriteProfileString("Y:\Stations.ini", "Printers", @WKSTA,$Printers[Val($s) - 1])
? "Printer changed to " + @WKSTA + "=" + $Printers[VAL($s) - 1]
ENDSELECT
EndFunction
[/code]

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#80468 - 2001-11-16 06:56 AM Re: Network Printer Connection
MCA Offline
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 ]

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#80469 - 2001-11-16 07:03 AM Re: Network Printer Connection
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear Chris Page,

The third part was also our problem. Only in this way we can put that part on the board.
We discover possible problems with the
"[code]" and "[/code]". Also
we found a lot of TAB characters in your file.

For the other readers: Chris and also we get the message from this board

we do not permit this HTML tag: Parenthesis in HTML tag

greetings.

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
Page 1 of 1 1


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

Who's Online
0 registered and 1045 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.058 seconds in which 0.024 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