Page 1 of 1 1
Topic Options
#74361 - 2003-04-09 10:39 AM Printer migration (again!)
Corky Offline
Fresh Scripter

Registered: 2002-01-11
Posts: 13
Hi

Firstly apologies for reposting this subject but its driving me rount the twist. [Confused] I also am trying to migrate users network printers between two print servers as per the link here.

Previous thread

Unfortunately I cannot get NTDocs/Lonkeros code to work and would appreciate and help or recommendations.
I have enclosed the script file which I am calling from my main login script.

code:
 

Break on

$pmap="\\shaw\netlogon\PRINTERS.INI"

FOR each $key in split(readprofilestring("$pmap","PRINTER_MAP",""),chr(10))
IF primapstate($key)
$nul=addprinterconnection(readprofilestring("$pmap","PRINTER_MAP",$key))
IF primapstate($key)=2
$nul=SETDEFAULTPRINTER (READPROFILESTRING("$pmap","PRINTER_MAP",$key))
ENDIF
$nul=delprinterconnection($key)
ENDIF
NEXT


Function PriMapState($_Pri)
IF len(readvalue("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Devices",$_Pri))
IF instr(readvalue("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device"),$_Pri)
$PriMapState=2
ELSE
$PriMapState=1
ENDIF
ENDIF
EndFunction


Heres the ini file that I am using for the printer mappings!

[PRINTMAP]
\\beckett\HP-CLR=\\dubrovfs01\HP-CLR
\\beckett\hp4000d1=\\dubrovfs01\hp4000d1
\\beckett\hp4050d1=\\dubrovfs01\hp4050d1
\\beckett\hp4100d1=\\dubrovfs01\hp4100d1
\\beckett\hp5si2=\\dubrovfs01\hp5si2
\\beckett\hp5si3=\\dubrovfs01\hp5si3
\\beckett\hp5si5=\\dubrovfs01\hp5si5
\\beckett\hp5si6=\\dubrovfs01\hp5si6
\\beckett\hp5si7=\\dubrovfs01\hp5si7
\\beckett\hp5si8=\\dubrovfs01\hp5si8
\\beckett\hp5si10=\\dubrovfs01\hp5si10
\\beckett\hp5si11=\\dubrovfs01\hp5si11
\\beckett\hp5si12=\\dubrovfs01\hp5si12
\\beckett\hp5si13=\\dubrovfs01\hp5si13
\\beckett\hp5si14=\\dubrovfs01\hp5si14
\\beckett\hp5si15=\\dubrovfs01\hp5si15
\\beckett\hp5si16=\\dubrovfs01\hp5si16
\\beckett\hp5si17=\\dubrovfs01\hp5si17
\\beckett\hp5si18=\\dubrovfs01\hp5si18
\\beckett\hp5si19=\\dubrovfs01\hp5si19
\\beckett\hp5si23=\\dubrovfs01\hp5si23
\\beckett\hp5si25=\\dubrovfs01\hp5si25
\\beckett\hp5si26=\\dubrovfs01\hp5si26
\\beckett\hp5si28=\\dubrovfs01\hp5si28
\\beckett\hp5si29=\\dubrovfs01\hp5si29
\\beckett\hp5si30=\\dubrovfs01\hp5si30
\\beckett\hp5si31=\\dubrovfs01\hp5si31
\\beckett\hp5si32=\\dubrovfs01\hp5si32
\\beckett\saturn=\\dubrovfs01\saturn

I have an NT Domain with mixed NT/W2K clients.

TIA

Top
#74362 - 2003-04-09 10:42 AM Re: Printer migration (again!)
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
sure.
see:
code:
FOR each $key in split(readprofilestring("$pmap","PRINTER_MAP",""),chr(10))

it reads from section "PRINTER_MAP".
then look at your ini-file, is there a section named like that?
_________________________
!

download KiXnet

Top
#74363 - 2003-04-09 10:58 AM Re: Printer migration (again!)
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
true, with one notice :

splitted readprofilestrings always have an empty last element so either a redim preserve or a condition check is necessary
_________________________



Top
#74364 - 2003-04-09 11:25 AM Re: Printer migration (again!)
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Also be aware that you cannot set the default printer using the printers share name. You must use the printer name.
Top
#74365 - 2003-04-09 11:28 AM Re: Printer migration (again!)
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
one notice to jochen's notice.
some cases that is needed alright but not in this particular script.

don't ask why as I don't want to start explaining.
anyway, it will just like it is.
_________________________
!

download KiXnet

Top
#74366 - 2003-04-09 11:40 AM Re: Printer migration (again!)
Corky Offline
Fresh Scripter

Registered: 2002-01-11
Posts: 13
Hi

Talk about a case of 'not being able to see the wood for the trees'.
Apologies for taking up your time with such stupid mistake that I have been staring at for the last two days.

Again many thanks!

TC [Smile]

Top
#74367 - 2003-04-09 11:52 AM Re: Printer migration (again!)
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Jooel,

Oh I see ... there are already conditions checked in the original script [Roll Eyes]

[ 09. April 2003, 11:54: Message edited by: jpols ]
_________________________



Top
#74368 - 2003-04-09 11:54 AM Re: Printer migration (again!)
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
no need.
it is same with all ini-files with this particular script.

you seem to try to make me explain it after all.
I won't.
maybe you could check into the script and see what I mean.
_________________________
!

download KiXnet

Top
#74369 - 2003-04-10 12:00 AM Re: Printer migration (again!)
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
see?
simple glance over it took care of that [Razz]
_________________________
!

download KiXnet

Top
#74370 - 2003-04-10 12:02 AM Re: Printer migration (again!)
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Yeah !

I promise from now on to LOOK at the SCRIPT samples before replying ... honestly [Roll Eyes] [Razz]

{edit: well ... still my statement is (generally) true [Big Grin] }

[ 09. April 2003, 12:05: Message edited by: jpols ]
_________________________



Top
#74371 - 2003-04-09 02:59 PM Re: Printer migration (again!)
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Corky,

This worked a treat..

Printer Migration

Notice: I used Doc's/Lonkero's code too. [Smile] However, I had to make a small modification to do a USE LPT1: on it.

Kent

[ 09. April 2003, 15:00: Message edited by: kdyer ]
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#74372 - 2003-05-06 07:30 PM Re: Printer migration (again!)
Anonymous
Unregistered


NT DOC & Lonkero are right on track. After trying to figure out how everything is pieced together, it works like a charm! Thanks!
Top
Page 1 of 1 1


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

Who's Online
0 registered and 1680 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.16 seconds in which 0.098 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