#172658 - 2007-01-11 12:29 AM
Using ini file to map printers
|
SeaSlug
Fresh Scripter
Registered: 2007-01-11
Posts: 9
|
Hi all,
Noobie here, just learning about Kixtart
Would like some help please.
I need to map a whole bunch of network printers, close to 50. These printers do get updated, and all users need to connect to all of them!
when I run the addprinterconnection, it take a while to map them all, so I wanted to map them only once, but when the admin adds a new printer, they can add it to an ini file and simply update the version number.
So I would have an ini file looking something like
[Version] Number=1.0
[Printers] \\pserver\printer1 \\pserver\printer2 \\pserver\printer3 etc to 50
So the admin simply updates the version number both in the ini file and the printer.kix script, and if it is different than the one refered to in the script script, then re-add all the printers.
Likewise, will do the same when pritners are going to be deleted.
Does this make sense?
Any advice and code welcome!
Thank you
|
Top
|
|
|
|
#172660 - 2007-01-11 12:39 AM
Re: Using ini file or basic file to map printers
[Re: Les]
|
SeaSlug
Fresh Scripter
Registered: 2007-01-11
Posts: 9
|
so would I need something like:
[Version] Number=1.0
[Printers] 1=\\pserver\printer1 2=\\pserver\printer2 3=\\pserver\printer3
taking a different tack, I am also thinking of keeping it simpler??
Have a file called printers.txt for example. Have all the printers in here.
When logging on, check existing printer connections in the users registry hive. Read the file entries
Somehow - not sure how compare the two and add or delete those that have been added to or deleted in the file.
Thanks
Edited by SeaSlug (2007-01-11 01:02 AM)
|
Top
|
|
|
|
#172664 - 2007-01-11 01:17 AM
Re: Using ini file or basic file to map printers
[Re: Les]
|
SeaSlug
Fresh Scripter
Registered: 2007-01-11
Posts: 9
|
So how would I go about enumerating the [Printers] list and then comparing that with the current list stored in HKCU\Printers\Connections for the user?
thanks
|
Top
|
|
|
|
#172666 - 2007-01-11 01:48 AM
Re: Using ini file or basic file to map printers
[Re: Les]
|
SeaSlug
Fresh Scripter
Registered: 2007-01-11
Posts: 9
|
Yes, that is exactly what I would like to do !!
So, I would create two arrays, then use ASCAN?
do you have any (simple) snippets of code I can use to begin better understanding how this is performed?
thanks in advance
Edited by SeaSlug (2007-01-11 01:50 AM)
|
Top
|
|
|
|
#172670 - 2007-01-11 02:42 AM
Re: Using ini file or basic file to map printers
[Re: Les]
|
SeaSlug
Fresh Scripter
Registered: 2007-01-11
Posts: 9
|
Thanks Les
Working on it now.
Neglected to mention that I need to check the users remote printer connections, so am making the changes now.
what I do notice, is that the output from HKCU\Printers\Connections is ,,Server\Printer, yet my ini file is \\server\Printer.
How would I go about changing the reference?
Thanks in advance
|
Top
|
|
|
|
#172672 - 2007-01-11 03:00 AM
Re: Using ini file or basic file to map printers
[Re: SeaSlug]
|
SeaSlug
Fresh Scripter
Registered: 2007-01-11
Posts: 9
|
Ah,
When I create the array, I can do a split/join to replace the ,, with \
then continue doing the rest.
Is that correct ?
Thanks
|
Top
|
|
|
|
#172675 - 2007-01-11 04:41 AM
Re: Using ini file or basic file to map printers
[Re: Les]
|
SeaSlug
Fresh Scripter
Registered: 2007-01-11
Posts: 9
|
Hi Les,
Yeap figured that one out with the keys/value.
What I couldn't figure was the split, join. I had it in the wrong spot
So far so good.
Last step, how do I go about comparing between the two arrays? Would I use ASCAN and check for the existance of the variable from the ini file against the registry array?
thanks for all your help so far!
Edited by SeaSlug (2007-01-11 05:21 AM)
|
Top
|
|
|
|
#172677 - 2007-01-11 05:49 AM
Re: Using ini file or basic file to map printers
[Re: Les]
|
SeaSlug
Fresh Scripter
Registered: 2007-01-11
Posts: 9
|
I managed to get something similiar going, though nowhere as elegant as yours.
I will incorporate your code into my script to make it look a bit better. Will help the admins out greatly that they only have to change 1 file to update the printers.
I agree with your logging comments, once I get the basic theory going, then I will work on the logging.
I can't thank you enough for helping me out BIG Double thumbs up to ya !! Your a legend !
BTW - what does the $RC = do ? Does that catch any output?
Thanks again.
|
Top
|
|
|
|
#172679 - 2007-01-11 06:26 AM
Re: Using ini file or basic file to map printers
[Re: SeaSlug]
|
SeaSlug
Fresh Scripter
Registered: 2007-01-11
Posts: 9
|
I noticed that when I do my check for the registry array contents against the ini file array, there appears to be 2 blank lines (cr/lf perhaps) that cause 2 errors to occur.
Any ideas?
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 507 anonymous users online.
|
|
|