<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ross' Cogitations &#187; Printing</title>
	<atom:link href="http://ross-family.org/blog/tag/printing/feed/" rel="self" type="application/rss+xml" />
	<link>http://ross-family.org/blog</link>
	<description>Thoughts on theology &#38; technology.</description>
	<lastBuildDate>Fri, 30 Jul 2010 22:35:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Printer Migration Client Script</title>
		<link>http://ross-family.org/blog/2009/11/03/printer-migration-client-script/</link>
		<comments>http://ross-family.org/blog/2009/11/03/printer-migration-client-script/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 19:04:38 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Printing]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[VBS]]></category>

		<guid isPermaLink="false">http://ross-family.org/blog/?p=124</guid>
		<description><![CDATA[If you have ever had to migrate all the printers from one Windows print server to another, the server side part is pretty easy.  Windows 2008 includes the Printer Migration Wizard which can migrate the queues.  Prior to Windows 2008 there was an outstanding utility called Print Migrator (PrintMig) which made it a snap. However [...]]]></description>
			<content:encoded><![CDATA[<p>If you have ever had to migrate all the printers from one Windows print server to another, the server side part is pretty easy.  Windows 2008 includes the Printer Migration Wizard which can migrate the queues.  Prior to Windows 2008 there was an outstanding utility called Print Migrator (<a title="Download PrintMig 3.1" href="http://www.microsoft.com/downloads/details.aspx?familyid=9b9f2925-cbc9-44da-b2c9-ffdbc46b0b17&amp;displaylang=en" target="_blank">PrintMig</a>) which made it a snap.</p>
<p>However the client side is a bit more tricky.  Since there is a different server name in the printer share path the clients will be broken after the migration.</p>
<p style="padding-left: 30px; ">Printer share  path on old server: \\OldPrnSrv\Printer1</p>
<p style="padding-left: 30px; ">Printer share path on new server: \\NewPrnSrv\Printer1</p>
<p>This problem can be further complicated if during the migration you took the opportunity to standardize Printer/Printer Share names.  I had this exact problem at a client.  I solved it with a GPO-based logon script and input file.  Before I go into how to implement this, first a little about the script.</p>
<ul>
<li>The script first checks for the existence of a &#8220;check&#8221; file.  If the check file exists then we assume the script already ran and we exit.</li>
<li>Then the script records the user&#8217;s default printer as it will need this info later to ensure the same device is set as default after the printer reconnect.</li>
<li>Next the script walks through the input file and attempts to disconnect each &#8220;old&#8221; printer connection and reconnect to the new.  If the printer share in the input file is not defined on the person&#8217;s machine then it skips that line and moves on to the next line/printer.</li>
<li>Once all the input file has been traversed the script resets the person&#8217;s default printer and creates the &#8220;check&#8221; file.</li>
</ul>
<p>Here is the script code.</p>
<pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee; font-size: 12px; border: 1px dashed #999999; line-height: 14px; padding: 5px; overflow: auto; width: 100%;"><code>On Error Resume Next
Const ForReading = 1

Set WshNetwork = CreateObject("WScript.Network")
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FileExists("c:\PrinterReconnectFinished.txt") then
Set f1 = fso.OpenTextFile(GetPath() &amp; "input.txt", ForReading)

varDefault = GetDefaultPrinter()

tmpArr = Split(f1.readall, vbcrlf)
for i = 0 to UBOUND(tmpArr)
    If instr(1, tmpArr(i), varDefault, 1) then x = i
    err.clear
    tmpVar = split(tmpArr(i), "~")
    WshNetwork.RemovePrinterConnection tmpVar(0)
    If err.number = 0 then WshNetwork.AddWindowsPrinterConnection tmpVar(1)
next

var1 = split(tmpArr(x), "~")
ConfigDefaultPrinter(var1(1))
    Set f2 = fso.CreateTextFile("c:\PrinterReconnectFinished.txt", True)
    Set f3 = fso.Getfile("c:\PrinterReconnectFinished.txt")
    f3.attributes = f3.attributes + 2
End If

'*************************************************************************************************
Sub ConfigDefaultPrinter(name)
        '*****************************************************************************************
        '*****************************************************************************************
        ' Purpose:  This sub routine defines a default printer based on the printer name passed to
        ' it.
        ' Version 1.0
        ' Arguements:  None
        '*****************************************************************************************
        '*****************************************************************************************
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" &amp; "{impersonationLevel=impersonate}!\\" &amp; _
    strComputer &amp; "\root\cimv2")
    Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer Where Name = 'name'")
    For Each objPrinter in colInstalledPrinters
            objPrinter.SetDefaultPrinter()
    Next
End Sub
'*************************************************************************************************

'*************************************************************************************************
Function GetDefaultPrinter()
        '*****************************************************************************************
        '*****************************************************************************************
        ' Purpose:  This Function returns the default printer as configured on the client.
        ' Version 1.0
        ' Arguements:  None
        ' Returns:  Text string
        '*****************************************************************************************
        '*****************************************************************************************
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" &amp; "{impersonationLevel=impersonate}!\\" &amp; _
    strComputer &amp; "\root\cimv2")
    Set colInstalledPrinters =  objWMIService.ExecQuery("Select * from Win32_Printer")
    For Each objPrinter in colInstalledPrinters
        If objPrinter.Default then
            GetDefaultPrinter = objPrinter.Name
        End If
    Next
End Function
'*************************************************************************************************

'*************************************************************************************************
Function GetPath()
    '*********************************************************************************************
    '*********************************************************************************************
    ' Purpose:  This Function returns the path where the script is currently being executed.
    ' Version 1.0
    ' Arguements:  None
    ' Returns:  Text string
    '*********************************************************************************************
    '*********************************************************************************************
    Dim path
    path = WScript.ScriptFullName
    GetPath = Left(path, InStrRev(path, "\"))
End Function
'*************************************************************************************************
</code></pre>
<p>Here&#8217;s how you can implement this solution.</p>
<p>1. Create an input file and put each old printer share path and new share path on a new line separated by a &#8220;~&#8221;.  It should look like this:</p>
<pre style="padding-left: 60px; ">\\OldPrnSrv1\Printer1~\\NewPrnSrv1\Printer1</pre>
<pre style="padding-left: 60px; ">\\OldPrnSrv1\Printer2~\\NewPrnSrv1\Printer1</pre>
<pre style="padding-left: 60px; ">etc...</pre>
<p>2. When you have all the printer share paths entered in your input file save it as <strong>input.txt</strong>.</p>
<p>3. Next download the printer migration script <a title="PrinterReconnect script." href="http://files.ross-family.org/PrinterReconnect.vbs.txt" target="_blank">here</a>.  Strip the &#8220;.txt&#8221; off of the end of the name.</p>
<p>4. Save the input.txt and script files in the domain scripts share (\\mydomain.com\SYSVOL\mydomain.com\scripts).</p>
<p>5. Create a new Group Policy Object (GPO) called <strong>Printer Reconnect</strong>. <strong>NOTE</strong>: <strong>Don&#8217;t</strong> link it to any container yet.</p>
<p>6. Edit the GPO under<strong> User Configuration</strong>&gt;<strong>Windows Settings</strong>&gt;<strong>Scripts</strong> double-click <strong>Logon</strong>.</p>
<p>7. Click the <strong>Add</strong> button, then <strong>Browse</strong>.  Locate/select the <strong>PrinterReconnect.vbs</strong> script in the path you saved it to previously.</p>
<p>8. Click <strong>OK</strong> and make sure the script is displayed on the <strong>Logon Properties</strong> screen.  Click <strong>OK.</strong></p>
<p>Once all printers are migrated to the new server and well tested, you should be ready to have the clients reconnect to the migrated queues on the new server.  ONLY when ready to have clients reconnect, go to the next step.</p>
<p>9. Link the <strong>Printer Reconnect</strong> GPO to an appropriate container to apply the logon script to targeted users.</p>
<p>As always, use this at your own risk.  Let me know if you have any issues and I will help out as I can.</p>
]]></content:encoded>
			<wfw:commentRss>http://ross-family.org/blog/2009/11/03/printer-migration-client-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
