#183420 - 2007-12-08 02:18 PM
Install Printers using IP?? Is it possible
|
rhunton
Fresh Scripter
Registered: 2007-12-08
Posts: 11
Loc: York, United Kingdom
|
Hi All, I am a complete n00b to kixtart scripting. I am not sure where to ask this question or if it is at all possible!! This is what I have at the moment.
Dim $defaultgw $defaultgw = EnumIPInfo($NIC,3) If $defaultgw == '192.168.1.1' "Your Default Gateway is: " + EnumIPInfo($NIC,3) USE K: '\\servername\servershare' else if $defaultgw == '192.168.2.1' USE L: '\\servername\servershare'
Now the problem I have now is I would like kix to install a printer on the detected network subnet. This would involve creating a new TCP/IP printer port and then installing the drivers. eg if 192.168.1.1 was detected it would install 192.168.1.2
Has anyone got any ideas on how to do this? The script would be rolled out to around 400 desktops and 350 laptops if it is possible!!!
Thanks for your help
Edited by rhunton (2007-12-08 02:43 PM)
|
Top
|
|
|
|
#183425 - 2007-12-08 04:23 PM
Re: Install Printers using IP?? Is it possible
[Re: rhunton]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4545
Loc: USA
|
Addprinterconnection() is the way to connect to NT Based print servers, and in most cases is the preferred way of doing things. Once the printer is setup on the server correctly, and then shared, it is simply a matter of using addprinterconnection. The configuration of the printer, and its drivers come over when you add the connection. It is built into kix. See the manual for further explanation.
Addprinter()is a User Defined Function. It provides a way to add a Local printer (including IP, LPT, COM) to a workstation. To install, it requires the print drivers be available, either on the pc or on the network. The user installing/running the script must be an Administrator of the PC. You also have to define the port, the name, amongst other settings. Addprinter() can be found here: http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=84165#Post84165
|
Top
|
|
|
|
#183426 - 2007-12-08 04:43 PM
Re: Install Printers using IP?? Is it possible
[Re: Allen]
|
rhunton
Fresh Scripter
Registered: 2007-12-08
Posts: 11
Loc: York, United Kingdom
|
Thanks for the help; I will give that a stab. I maybe should have said the computers are distributed throughout the UK. We have several regional offices and about 50 building sites all connected back with ADSL. Depending on the site we may only have 2 PC’s to 1 printer others can have 15 PC’s to 1 printer. I will work on it and the bigger sites may just warrant a print servers
Cheers Guys
|
Top
|
|
|
|
#183431 - 2007-12-08 11:44 PM
Re: Install Printers using IP?? Is it possible
[Re: rhunton]
|
rhunton
Fresh Scripter
Registered: 2007-12-08
Posts: 11
Loc: York, United Kingdom
|
Help with AddPrinter() - Add IP,LPT, or COM Printers.
I have been playing about with the script that you advised me to use but am unable to make any use of it.
The part that I am finding hard to understand is when a line starts with a; - does that mean its commented out. It does in VB? Also, in the script where do you declare all the information? Is it all under the parameters section that I though was commented out?
|
Top
|
|
|
|
#183438 - 2007-12-09 11:01 AM
Re: Install Printers using IP?? Is it possible
[Re: Gargoyle]
|
rhunton
Fresh Scripter
Registered: 2007-12-08
Posts: 11
Loc: York, United Kingdom
|
Hi, thanks for the reply. I just need one last bit of help please.
When you are defining the informtion, how do you format it? for example take $port = Does the information have to be contained between the brackets or do you just type 192.168.1.1, "192.168.1.1", (192.168.1.1), ("192.168.1.1")
I think once I know the answer to this it should be pretty stright forward
;Parameters: ; $Port = "192.168.1.1" ; IPAddress(RAW) (xxx.xxx.xxx.xxx) ; IPAddress(LPR) (xxx.xxx.xxx.xxx:LPRQueueName) ; LPT (LPT1:) ; COM (COM1:) ; PrintServer (\\server\printer)
Thanks again
|
Top
|
|
|
|
#183440 - 2007-12-09 05:03 PM
Re: Install Printers using IP?? Is it possible
[Re: Les]
|
rhunton
Fresh Scripter
Registered: 2007-12-08
Posts: 11
Loc: York, United Kingdom
|
Thanks for the help guys. All working now!!
Is it possible to skip a printer install if it is currently installed? When I run the script I end up with printer1, printer1 (copy 1), printer1 (copy2) etc.
Thanks
|
Top
|
|
|
|
#183441 - 2007-12-09 05:08 PM
Re: Install Printers using IP?? Is it possible
[Re: rhunton]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4545
Loc: USA
|
|
Top
|
|
|
|
#183442 - 2007-12-09 08:56 PM
Re: Install Printers using IP?? Is it possible
[Re: Allen]
|
rhunton
Fresh Scripter
Registered: 2007-12-08
Posts: 11
Loc: York, United Kingdom
|
Hi All, On a seperate note how would I do the following? I would like to pass the result of EnumIPInfo($NIC,3) into a variable.
This is what I have at the moment
Dim $defaultgw $defaultgw = EnumIPInfo($NIC,3)
If $defaultgw == '192.168.1.1' "Your Default Gateway is:" + EnumIPInfo($NIC,3) call "another kix script" else endif If $defaultgw == '192.168.2.1' else endif
Have I got the part correct about passing the result of EnumIPInfo($NIC,3) into the variable?
Thanks
Edited by rhunton (2007-12-09 09:05 PM)
|
Top
|
|
|
|
#183444 - 2007-12-09 10:19 PM
Re: Install Printers using IP?? Is it possible
[Re: Les]
|
rhunton
Fresh Scripter
Registered: 2007-12-08
Posts: 11
Loc: York, United Kingdom
|
Hi Les, The $NIC is querying my network card information.
The idea to the script: When I get a user plugs into one of our remote networks for the first it will install the printers for that network on the users pc.
I just remember from my Visual Basic days at college that == worked and I just gave it a try - i am guessing that = will work just as well.
Will I get away without putting else statements in the code?
I have got the code running now and thanks to the scripts from Allen all is working great.
I have no doubt that I will run into problems in the future so will be in contact again.
Thanks All
Rob
Edited by rhunton (2007-12-09 10:19 PM)
|
Top
|
|
|
|
#183446 - 2007-12-09 10:56 PM
Re: Install Printers using IP?? Is it possible
[Re: Les]
|
rhunton
Fresh Scripter
Registered: 2007-12-08
Posts: 11
Loc: York, United Kingdom
|
The EnumIPInfo($NIC,3) is calling information from my network card. IE Static address or DHCP Address From what I read; EnumIPInfo($NIC,1) = IP Address EnumIPInfo($NIC,2) = Subnet Mask EnumIPInfo($NIC,3) = Default Gate
I just googled the problem it turned up that code.
I have now got to implement it in an Active directory to see what the result is.
Hope the above is use to other people.
Edited by rhunton (2007-12-09 10:57 PM)
|
Top
|
|
|
|
#183464 - 2007-12-10 04:37 PM
Re: Install Printers using IP?? Is it possible
[Re: Les]
|
rhunton
Fresh Scripter
Registered: 2007-12-08
Posts: 11
Loc: York, United Kingdom
|
Hi Les, Thanks for that. I realized that when you have multiple network cards like in a laptop you need to query all of them to see which is connected. The script now runs:
Dim $defaultgw0
Dim $defaultgw1
Dim $defaultgw2
$defaultgw0 = EnumIPInfo(0,3)
$defaultgw1 = EnumIPInfo(1,3)
$defaultgw2 = EnumIPInfo(2,3)
If $defaultgw0 = '192.168.1.1' or $defaultgw1 ='192.168.1.1' or $defaultgw2 ='192.168.1.1'
call file.kix
Works a treat now and it works with laptops and desktop.
I see where you were coming from now.
Thanks!!
Edited by rhunton (2007-12-11 12:04 PM)
|
Top
|
|
|
|
#183491 - 2007-12-11 04:36 PM
Re: Install Printers using IP?? Is it possible
[Re: Mart]
|
rhunton
Fresh Scripter
Registered: 2007-12-08
Posts: 11
Loc: York, United Kingdom
|
Hi All, I have been looking at the DelPrinterConnection() but it looks like it will not remove the local printers.
I can get rid of the network ones - thats great but ideally need a scipt that will work with local printers as well.
I know that this command works:
if printerexist("OKI B4350 (Test Printer1)")
run '%COMSPEC% /C START rundll32 printui.dll,PrintUIEntry /dl /n "OKI B4350 (Test Printer1)"
endif
but would like to keep all the kix scripts kixy not having to call cmd commands in the middle of scripts.
Also if I use the above code I get windows shouting at me saying that it is not installed or has been removed.
Thanks
Edited by rhunton (2007-12-11 04:52 PM)
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 515 anonymous users online.
|
|
|