Many people asked on newsgroup how to migrate from a printer server to another, without manual intervention off course.

1/Migrate drivers and declared printer with print migrator from Microsoft:

http://www.microsoft.com/downloads/details.aspx?FamilyID=9b9f2925-cbc9-44da-b2c9-ffdbc46b0b17&displaylang=en

2/

Use the following simple vbscript. Jut replace MYNEWPRINTERSERVER with the new print server name.

You may call it with cscript to not send popup, or remove wscript.echo to not warn user.

The best way is during logon script

The new print server must be already online and ready, as it removes the current printer and map again on the new print server

You can download it attached

here is the code source:

———————————————-

On Error Resume Next
Function GetDefaultPrinter()
sRegVal = « HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device »
sDefault = «  »
On Error Resume Next
sDefault = objShell.RegRead(sRegVal)
sDefault = Left(sDefault ,InStr(sDefault, « , ») – 1)
On Error Goto 0
GetDefaultPrinter = sDefault
End Function

Set objNetwork = CreateObject (« Wscript.Network »)
Set objShell = CreateObject (« WScript.Shell »)
Set objFSO = CreateObject (« Scripting.FileSystemObject »)

LogonServer = objShell.ExpandEnvironmentStrings(« %logonserver% »)
UserName = objShell.ExpandEnvironmentStrings(« %username% »)

strComputer = « . »
PrintServer = « MYNEWPRINTERSERVER »
PrintServer = LCase (PrintServer)

Err.Clear
Set objWMIService = GetObject(« winmgmts: » & _
« {impersonationLevel=Impersonate}!\\ » & strComputer & « \root\cimv2″)

If Err.Number Then
wscript.echo (« Error :  » & Err.Number & « :  » & Err.Description & VbCrLf)
Err.Clear

Else
ImpDefault = GetDefaultPrinter
Set colInstalledPrinters = objWMIService.ExecQuery _
(« SELECT * FROM Win32_Printer »)
For Each objPrinter in colInstalledPrinters
PrinterArray = Split (objPrinter.Name , « \ »)

If (LCase(objPrinter.ServerName) <> «  ») and (LCase(objPrinter.ServerName) <> « \\ » & PrintServer) then

objNetwork.AddWindowsPrinterConnection « \\ » & PrintServer & « \ » & PrinterArray(3)
If Err.Number Then
wscript.echo (« Error :  » & Err.Number & « :  » & Err.Description & VbCrLf)
Err.Clear
End If

If ImpDefault = objPrinter.Name then
objNetwork.SetDefaultPrinter (« \\ » & PrintServer & « \ » & PrinterArray(3))
End If

objNetwork.RemovePrinterConnection objPrinter.Name
End If
Next
End If

——————-

Popularity: 6% [?]