Microsoft KB Archive/304767

= How to Alter Behavior of Printers That Roam with Roaming Profiles =

Article ID: 304767

Article Last Modified on 8/6/2007

-

APPLIES TO


 * Microsoft Windows 2000 Service Pack 1
 * Microsoft Windows 2000 Service Pack 2

-



This article was previously published under Q304767



IMPORTANT: This article contains information about modifying the registry. Before you modify the registry, make sure to back it up and make sure that you understand how to restore the registry if a problem occurs. For information about how to back up, restore, and edit the registry, click the following article number to view the article in the Microsoft Knowledge Base:

256986 Description of the Microsoft Windows Registry



SUMMARY
By design, when a user is using a roaming profile, that user's default printer roams with the user profile. However, in some environments this may not be the desired behavior. This article provides methods you can use to alter this behavior.



MORE INFORMATION
WARNING: If you use Registry Editor incorrectly, you may cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that you can solve problems that result from using Registry Editor incorrectly. Use Registry Editor at your own risk.

IMPORTANT: The information in this article is designed for use by corporate administrators. Before you use any of the methods that are described in this article in your environment, you should thoroughly test the method in a test environment.

Printers are designed to roam with a user's roaming profile, and this is why the default printer is stored under the HKEY_CURRENT_USER branch of the registry. To alter this behavior, use either of the following methods.

Method 1
Export the default printer setting for an already-installed printer, and then merge the setting into the user's profile when the user logs on to the computer:  Use Registry Editor (Regedit.exe) to export the following registry key:

HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows

 Modify the registry (.reg) file you made in step 1 with a text editor so that the only registry value name below the key is:

&quot;Device&quot;=...

Note that the registry file should contain a blank line at the bottom of the file. Use Registry Editor (Regedit.exe) to add a new ResetPrinter string value under the following registry key:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run

 The value of the ResetPrinter value should be something similar to the following value

REGEDIT.EXE -S path\File.reg

where File.reg is the name you used to store the default printer.

Method 2
If computers in a specific area contain similar computer names, you can use a .vbs script file that matches a specific set of characters in the computer name, and installs a corresponding printer. The sample code that is included in this method only requires that you modify the IF lines. For example, the first IF statement in the code translates to &quot;if the computer name contains the text &quot;LAB1-&quot;, then set the default printer to &quot;\\LAB1\LaserJet&quot;. To complete this method:   Copy the following sample VBS code into a. vbs file, for example, Defaultprinter.vbs: Option Explicit DIM RegEntry, ComputerName

RegEntry=&quot;HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName&quot; ComputerName = ReadRegValue(RegEntry)

if InStr(1,ucase(ComputerName),&quot;LAB1-&quot;,vbTextCompare) > 0 then call SetPrinter(&quot;\\LAB1\LaserJet&quot;) if InStr(1,ucase(ComputerName),&quot;LAB2-&quot;,vbTextCompare) > 0 then call SetPrinter(&quot;\\LAB2\LaserJet&quot;) if InStr(1,ucase(ComputerName),&quot;OFFICE-&quot;,vbTextCompare) > 0 then call SetPrinter(&quot;\\OFFICE\LaserJet&quot;) 'so on and so forth. wscript.quit

' *** This subroutine installs and sets the default printer Sub SetPrinter(ByVal PrinterPath) DIM WshNetwork Set WshNetwork = CreateObject(&quot;WScript.Network&quot;) WshNetwork.AddWindowsPrinterConnection(PrinterPath) WshNetwork.SetDefaultPrinter Printerpath end sub

' **** This function returns the data in the registry value Function ReadRegValue(ByVal RegValue) DIM WSHShell Set WSHShell = WScript.CreateObject(&quot;WScript.Shell&quot;) ReadRegValue=&quot;&quot; On Error Resume Next ReadRegValue= WSHShell.RegRead(RegValue) End Function </li> Modify the IF lines as needed. The only portion of the IF lines that need to be modified is between double quotes. Note that you may need to add additional IF lines.</li> Use Registry Editor to create a ResetPrinter string value under the following registry key:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run

</li> The value of ResetPrinter should be something similar to the following value

WSCRIPT.EXE path\DefaultPrinter.vbs

where path is the location where the Defaultprinter.vbs file is stored.</li></ol>