Default printer problems and fix

We were experiencing some issues with customers and default printer changes.
No matter what settings we use we still encountered change of default printer.

Did some research and found that the NTUSER.DAT file seems corrupted, or something set wrong in the file.
The NTUSER.DAT file is a registry file. Every user profile created on a Windows operating system has an NTUSER.DAT file. A user profile contains personal files and preference settings that are specific to each user. For example, each user profile contains a unique Documents folder, Start Menu configuration, DEFAULT PRINTER SETTINGS.

The only thing seem to fix this was recreating the user profile, copying the new NTUSER.DAT to the old profile, and start using the old profile again.

Discovered that deleting all the printer setting data in the NTUSER.DAT will fix this issue as well.
You can load the NTUSER.DAT in the regedit.exe tool.

1. Start -> Run -> regedit
2. Click HKEY_USERS
3. File, Load Hive, browse to the user profile directory and select NTUSER.DAT
4. Specify “TempHive” if prompted for a name
5. Browse to HKEY_USERS\TempHive\Software\Microsoft\Windows NT\CurrentVersion\Windows
6. Look for a key named “Device” of type REG_SZ and delete it.
7. Browse to HKEY_USERS\TempHive\Software\Microsoft\Windows NT\CurrentVersion\Devices
8. Delete the Devices key with and recreate it again.
9. Browse to HKEY_USERS\TempHive\Printers\Connections
10. Delete the Printers key with and recreate it again.
11. Click HKEY_USERS
12. File, Unload Hive

But what if you have to do this for hunderds of users?
Wrote a powershell script to do this. 🙂
1. Find the NTUSER.DAT files
2. Load the file with reg.exe
3. Delete all printers settings with function “CleanPrinters”
4. Unload the file with reg.exe

Function CleanPrinters {

## Delete all known printers
$RegKey = "HKLM:\temphive\Software\Microsoft\Windows NT\CurrentVersion\Devices"
Remove-Item -Path $regkey
New-Item -Path $regkey

## Delete Device key
$RegKey2 = "HKLM:\temphive\Software\Microsoft\Windows NT\CurrentVersion\Windows"
Get-item $RegKey2 | Select -ExpandProperty "Property" | % {
$key2 = $_
If ($key2 -eq "Device") {
Remove-ItemProperty -Name $key2 -Path $RegKey2
}

} #end Delete Device key


## Delete Printer connections
$RegKey3 = "HKLM:\temphive\Printers\Connections"
Remove-Item -Path $regkey3
New-Item -Path $regkey3

} #end Delete Printer connections


## Search ntuser.dat and use function CleanPrinters for each
$path = "H:\Share\Sales\Profiles$"

$files = Get-ChildItem -Path $path -include ntuser.dat -Recurse -ErrorAction SilentlyContinue -force

$files | foreach {

$ntuserfile = $_.Fullname

$TempHive       = "HKLM\TempHive"
reg load $TempHive "$ntuserfile"

CleanPrinters

reg unload $TempHive
}

Change the $path, and use at the above at your own risk.

4 thoughts to “Default printer problems and fix”

  1. Thanks for the post, I think this might solve a problem I am having.
    You say “Delete the Devices key with and recreate it again” Can you please clarify, “keys with” what?
    Many thanks.

    1. Hi Matt,

      Delete the whole key “Devices”

      Then right click “Current Version”, “New”, “Key”, and name it “Devices”.

      Hope it helps.

  2. My problem was certain user cannot open printer dialog or printer control panel setting.

    I apply your procedure and it worked, thanks a lot!

    It was a windows server 2016 with RDP users.

    Thanks a lot!

Leave a Reply

Your email address will not be published. Required fields are marked *