Page 1 of 1 1
Topic Options
#135995 - 2005-03-21 10:54 AM printermover() - move user printers during logon.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
couldn't easily find anything fresh about it so decided to post mine.
it has proven to work 100% so many times and is quite simple so lets push the logic.

the mover itself is quite simple:
Code:

;printer mover
;###########################

function printermove()
dim $,$printer,$new
for each $printer in split(left(readprofilestring(@ldrive+"control\printermove.ini","",""),-1),chr(10))
; ? "checking printer: " $printer
if primapstate($printer)
$new=readprofilestring(@ldrive+"control\printermove.ini",$printer,"newshare")
$=addprinterconnection($new)
; if @error mail("printermove failure","error occured while tried to connect to new printer share ("+$new+"): @serror") exit 0 endif
if 2=primapstate($printer)
$new=readprofilestring(@ldrive+"control\printermove.ini",$printer,"newname")
$=setdefaultprinter($new)
; if @error mail("printermove failure","error occured while tried to set new printer ("+$new+") as defaul: @serror") exit 0 endif
endif
$=delprinterconnection($printer)
; if @error mail("printermove failure","error occured while tried to disconnect from old printermap ("+$printer+"): @serror") exit 0 endif
; mail("printermove success","printermove of "+$printer+" to "+$new+" was carried out successfully.")
endif
next
endfunction



my version has two dependies, mail() which is just smtp-wrapper and primapstate() that is foundable on the board too.
if you don't need to get success mails, you can leave the mail lines commented out.
also, I have that first commented out line uncommented IRL as my logonscript runs windowless (with wkix32) and all console output is pushed to logon.log for later examination.
ini-file would look simple as:
Code:

[\\secondsrv\ibmMatrix]
newshare=\\theNewShinyStar\ibmMatrix1
newname=\\theNewShinyStar\the old ibm matrix



now, the section name is the old sharename that primapstate checks from the clients registry.
if the user has it mapped, it will be remapped to the new location.
if user had it default, the new share will be set to default.
then the old one gets deleted.

what comes to the logic...
I have also made script that maps drives (group drives and such) based on it.
just not using in production yet. iirc.
_________________________
!

download KiXnet

Top
#135996 - 2005-03-21 02:48 PM Re: printermover() - move user printers during logon.
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Now.. We need to incorporate the following to this which would complete the task - Delete/Refresh Print Drivers

Kent

_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#135997 - 2005-03-21 04:57 PM Re: printermover() - move user printers during logon.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
what you mean?
your code is playing with the driver, right?
this code overwrites the old driver when the new connection is made...
not sure I follow.
_________________________
!

download KiXnet

Top
#135998 - 2005-03-21 06:10 PM Re: printermover() - move user printers during logon.
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
With my code, you can remove old drivers. I think it would be cool to remove all old drivers before adding in any new printers. We have had a number of Support Desk calls resolved by removing 10 or so drivers (even though they had one printer) and then just adding in one printer.

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#135999 - 2005-03-21 06:18 PM Re: printermover() - move user printers during logon.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
interesting...
_________________________
!

download KiXnet

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 1471 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.056 seconds in which 0.027 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