Page 1 of 1 1
Topic Options
#157947 - 2006-02-28 01:28 PM Add new printer
JohnLennon Offline
Fresh Scripter

Registered: 2006-02-28
Posts: 5
Instead of move a printer (wich i found on these forums) i'm looking for a script to add a new printer includes the driver. Also with possibility to configure the settings.
Can anyone help me ? I looked everywhere, but even in the usermanuel i can't find the solution.

ps.

i want to add this script for my RIS installation (unattended for winXP)

Top
#157948 - 2006-02-28 01:56 PM Re: Add new printer
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
add printer?
is it local printer?
if yes, it is installed automatically, no?
if not, use addprinterconnection() as descriped in manual.
_________________________
!

download KiXnet

Top
#157949 - 2006-02-28 01:57 PM Re: Add new printer
JohnLennon Offline
Fresh Scripter

Registered: 2006-02-28
Posts: 5
It is a networkprinter. If i use addprinterconnection() how can i link it to his IP ?
Top
#157950 - 2006-02-28 02:06 PM Re: Add new printer
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
you are not using printer server but directly connecting to the printers port?
_________________________
!

download KiXnet

Top
#157951 - 2006-02-28 02:07 PM Re: Add new printer
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
Hi JohnLennon and welcome to korg,
Not sure if this is what you are looking for but maybe it’s a start. For these functions to work you must have the printer drivers already installed.

Code:

$OperatingSystem = @PRODUCTTYPE
AddPrinter("\\ServerName\PrinterShareName")
SetDefPrinter("\\ServerName\PrinterShareName")

Function AddPrinter($PrinterLocation)
If InStr($OperatingSystem,"Server")
$WshNetwork = CreateObject("WScript.Network")
$WshNetwork.AddWindowsPrinterConnection($PrinterLocation)
Else
$= AddPrinterConnection($PrinterLocation)
EndIf
EndFunction

Function SetDefPrinter($PrinterLocation)
If InStr($OperatingSystem,"Server")
$WshNetwork = CreateObject("WScript.Network")
$WshNetwork.SetDefaultPrinter($PrinterLocation)
Else
$= SetDefaultPrinter($PrinterLocation)
EndIf
EndFunction

_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#157952 - 2006-02-28 02:12 PM Re: Add new printer
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
benny, your udf's are just wscript versions of the inbuilt kixtart functions and nobody should use them for anything but testing because of the extra overheat, right?

but if he is talking about IP printer, he can use instead of the addprinterconnection() this udf by Allen:
http://www.kixtart.org/UDF/UDF_lister.php?what=post&code=83350
_________________________
!

download KiXnet

Top
#157953 - 2006-02-28 02:25 PM Re: Add new printer
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
JohnLennon,
Jooel will be a much better guide for you and will be able to give you better advice.


Edited by benny69 (2006-02-28 02:26 PM)
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#157954 - 2006-02-28 02:36 PM Re: Add new printer
JohnLennon Offline
Fresh Scripter

Registered: 2006-02-28
Posts: 5
Jooel,
if i look at the script (from Allen) i see the green text, but what must i change to config it to my personal settings ?

This line:
$=WriteValue($IPPrinterKey,"IPAddress","$Port","REG_SZ")

or:
; IPAddress (xxx.xxx.xxx.xxx)

Top
#157955 - 2006-02-28 03:10 PM Re: Add new printer
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
it's udf and what you need to do is place the whole code somewhere in your script file.
normally it's right at the end.
then you use it like any kixtart's internal function.
the examples section in the green... the first line probably is the way you are wanting to do it.

benny, sorry if I depressed your helping will...
_________________________
!

download KiXnet

Top
#157956 - 2006-02-28 03:15 PM Re: Add new printer
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
na, you da man!
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#157957 - 2006-03-01 10:07 AM Re: Add new printer
JohnLennon Offline
Fresh Scripter

Registered: 2006-02-28
Posts: 5
The lines after the ";" symbol doesn't count ?
Top
#157958 - 2006-03-01 11:54 AM Re: Add new printer
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
; is a single line comment symbol.
so each line starting with it (they are colored green in the post) are informatic comments.
_________________________
!

download KiXnet

Top
#157959 - 2006-03-01 12:53 PM Re: Add new printer
JohnLennon Offline
Fresh Scripter

Registered: 2006-02-28
Posts: 5
o.k. so it doesn't matter if i delete those lines
Top
#157960 - 2006-03-01 02:12 PM Re: Add new printer
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, basically not.
but you should not.
if you place the whole code right after your script, at the very end, they are not bothering you at all but they do inform you about the usability and such of the UDF.

so, for your own good, you should just simply copy everything from the first line that says:
;function

to the very last:
endfunction

just as it is into your script file.
unmodified and 100% functional, tested and proved code.
_________________________
!

download KiXnet

Top
#157961 - 2006-03-01 02:48 PM Re: Add new printer
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Or just paste the entire UDF code into a separate file, save the file in the same dir your script is or create a functions dir inside the dir your script is in (I prefer the second option) and call the function once at the beginning of your script. This way they are not in your primary script and can still be used but they just don't make your script that long.
This way you will also get a nice clean separation between your code and code somebody else wrote.

Code:

Call @scriptdir + "\SomeFunction.kix"

All other ode goes here



or

Code:

Call @scriptdir + "\functions\SomeFunction.kix"

All other ode goes here

_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

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 248 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.068 seconds in which 0.024 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org