Here is some code that I wrote to migrate printers from an old server to a new server. This scripts assumes a couple things:

* - Only Win95 systems...sorry
* - Print share names must be the same on old and new server.

code:

; ---------- PRINTMIG.KIX ----------------------------------
;
; Created by: Roneil Icatar
; Company: GE Capital IT Solutions
; Date: 4/18/2000
; E-mail: roneil.icatar@gecits.ge.com
; Phone: 860.571.4516
;
; --------------------------------------------------------------
;
; This script is used to migrate users from the old print server
; to the new server. It does this by scanning the correct part
; of the registry and replacing the old server with the new server.
; This script determines the user's servers from the server.txt file
; on the user's PUBLIC share.
;
; ---------- Change Log --------------------------------------
; When Who What
;
;
;
;

IF @INWIN = 1 ;if user is running Windows NT, skip to end
goto end
ENDIF

IF $OPTION = "1"
GOTO INTERACTIVE ; Interactive mode prompts the user for old and new server
ENDIF

;This section reads the servers.txt file from the P drive
;to find the old and new server names
:GETSERVER
IF Open(1,"P:\Migration\Servers.txt",2) = 0
$OLDSERVER = ReadLine(1)
$NEWSERVER = ReadLine(1)
? "Old server is: $OLDSERVER"
? "New server is: $NEWSERVER"
? Close (1)
GOTO CONTINUE
ELSE
GOTO INTERACTIVE ; If the servers.txt file cannot be found, go interactive
ENDIF

:INTERACTIVE
IF $OLDSERVER = ""
? "Enter the old server name: "
GETS $OLDSERVER
ENDIF

IF $NEWSERVER = ""
? "Enter the new server name: "
GETS $NEWSERVER
ENDIF

:CONTINUE
$L = LEN($OLDSERVER)

$HomeKey = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print\Printers"
$index = 0 ; This index is used to count how many printers are installed
$count = 0 ; This count is used to determine how many printers have been changed
:GetKey
$KeyName = EnumKey($HomeKey,$index) ;read the next printer name
if @error = 0
$FullKey = $HomeKey + "\" + $KeyName ;get the full path for the printer registry key
? "Name found: $FullKey"
$Port = READVALUE($FullKey,"Port") ;get the port for current printer
? "Printer port: $Port"
;if the old server name is in the port, replace it with the new server name
if INSTR($PORT,$OLDSERVER)
$Prt = SUBSTR($PORT,$L + 3,99) ;separate the printer share name from the port name
? "Printer name: $Prt"
$NewPort = "\\" + $NEWSERVER + $Prt ;generate new port using new server and printer share
? "New Port will be: $NewPort"
WriteValue($FullKey,"Port",$NewPort,"REG_SZ") ;write this new port to the registry
if @ERROR = 0 ;if successful, write to the log file
OPEN(2,"C:\CHECKAPP\PrintMig.log",5)
WRITELINE(2,"Successfully moved printer " + $Prt + " from " + $OLDSERVER + " to " + $NEWSERVER)
$count = $count + 1 ;increase the count of printers migrated
else
BEEP
? "There was an error redirecting your printers. Please contact the Help Desk."
OPEN(2,"C:\CHECKAPP\PrintMig.log",5)
WRITELINE(2,"Errors while moving printer " + $Prt + " from " + $OLDSERVER + " to " + $NEWSERVER)
endif
endif
$index = $index + 1 ;increment index for next pass
goto GetKey ;loop and read next printer
Endif

:END
; If a printer has been migrated, the user will have to reboot for the change
; to take effect. This section checks to see if the count is greater than 1.
; If so, display a message for the user to reboot their computer.
if $count > 0
? "Please reboot your computer for the changes to take effect."
? "Press any key to continue ..."
get $x
endif
EXIT


Roneil