VMware Horizon Community
eXPlosionas
Enthusiast
Enthusiast

Default printer is not remembered in VDI

Hi,

we have vmware vSphere6 and VDI desktop infrastructure. Every time user loggs in into VDI his default printer is not the printer which it made default in previous login. Vm pool is Automated Desktop Pool with source vCenter (linked clone). This happens on win8 or win10, it doesn't matter.

I found this in discussion:

I found the sollution eventually.

Its realated to the "network location awareness" service

2 options:

[s]1. (for every user) disable the "Network Location Awareness" Service in the services console and include it in your gold image

(i believe its related to: every guest generates there own network ID, if the ID is different NLA sets the default printer to the system default (which in my case is the PDF creator)[/s] (sorry guys, this was NOT the sollution)

2. If you do not want to disable the NLA service,  Do it on a per-user base in the current user registry (see below)

Create a Key in HKEY_CURRENT_USER\Printers ... named: Defaults

Then create an entry (string value): Disabled and set it to: 1

--- printer_per_user.reg ----

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Printers\Defaults]
"Disabled"="1"

but registry editing and disabling service didn't helped. Any more ideas?

18 Replies
cH1LL1
Enthusiast
Enthusiast

Use Client Side Preferences:

Group Policy:

User Configuration:>Preferences>Control Panel Settings>Printers> Shared Printer>

Set the printer as a default Printer> True

Only if a local printer is not present: True/False

You can also item level target this to a security group of users or a OU where your users are based./

Departmental/ Office etc.

there is another way...if you dont want to use Client Side preferences

Essentially you are going to create a script to write your currently saved  default printer to a network drive upon logoff.

then upon logon you will create a scheduled task to copy that default printer info from text file back in to the registry.

this is an exact copy of the script we are using to do this today across 650 vms

Save Printer script:

Dim objFSO 'As FileSystemObject

Dim objTextFile 'As Object

Set oShell = CreateObject("WScript.Shell")

strValue = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device"

strPrinter = oShell.RegRead(strValue)

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objTextFile = objFSO.CreateTextFile("p:\defaultPrinter.txt", True)

objTextFile.Write (strPrinter)

objTextFile.Close

Restore Printer Script:

On Error Resume Next

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.OpenTextFile("p:\defaultprinter.txt", 1)

If Err.Number <> 0 Then

  wscript.echo("Quiting")

  WScript.Quit

End If

Dim arrFileLines()

strPrinter = objFile.ReadLine

objFile.Close

Set oShell = CreateObject("WScript.Shell")

strKey = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device"

oShell.RegWrite strKey, strPrinter, "REG_SZ"

Reply
0 Kudos
eXPlosionas
Enthusiast
Enthusiast

Is it ok to use it together with:

--- printer_per_user.reg ----

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Printers\Defaults]
"Disabled"="1"

Reply
0 Kudos
VMMalley
Enthusiast
Enthusiast

another more drastic approach is to uncheck the remote printer deal during install of the 32/64 bit Horizon View agent.

This also works, but you lose the capability to have a locally connected printer if running from a standard PC or from home via your security server.

Reply
0 Kudos
eXPlosionas
Enthusiast
Enthusiast

The printer is remembered now, but when going to file -> print in word or excel it just hangs. The same happend when i want to open printers and devices. The control panel window freezes. This happened before the registry manipulation. It happens mostly on few VDI's. I don't know what to look for.

Reply
0 Kudos
eXPlosionas
Enthusiast
Enthusiast

Everytime i check this logof logon script in vSphere client it works, printer is set, but when in the morning our employee comes and logs in to vdi it's not saved as default printer. Maybe i should set some delay to script because maybe boot process have not completed fully

Reply
0 Kudos
CyberTron123
Enthusiast
Enthusiast

Hi

We´ve had the same problem but we have "solved" it. It is related to 2 services, "TP AutoConnect service" and "TP VC GateWay Service"

These maps local printers (connected from usb) on a laptop/ordinary client. These services remaps the default printer to the local printer, and if no local printer exists it remaps it to a "vdi local" printer (such as Pdf Writer or similar) and in last case it remaps it to a network printer (randomly)

Disable those services and your Default Printer will work like 99% of the time.

However, your users can´t use locally connected printers from their laptop and have ThinPrint connect the printer to the VDI if these services is disabled.

hope it helps

it took us forever to find out a solution.

eXPlosionas
Enthusiast
Enthusiast

Actually it solved the problem for two month after disabling those two TP services. But after a while it started to appear again. Print Spooler service just hangs and cannot stop or restart it.

Reply
0 Kudos
jbc974
Contributor
Contributor

Hi,

To solve this issue that vmware seems to ignore, even if it is really annoying, here is the tip we use in our VDI infrastructure.

Windows logoff script (Windows local group policies) :

reg delete "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\SessionDefaultDevices" /f

reg export "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows" "%APPDATA%\defaultprt.reg" /y

Windows logon script :

ping localhost -n 30

reg delete "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\SessionDefaultDevices" /f

ping localhost -n 2

reg import "%APPDATA%\defaultprt.reg"

It has been working for almost 2 years now.

Hope it can help those who get this problem.

Philippe

Ray_handels
Virtuoso
Virtuoso

There might just be an easier solution.

We found out that ThinPrint (as stated by someone else) tries to set the default printer every time you log into View.

There is a registry key that disables this behaviour without doing other stuff that might damage printing.

Try to add (it doesn't exist by default) the following key

HKLM\Software\ThinPrint\TPAutoConnect\DisableSettingOfDefPrinter=1 (DWORD)

cH1LL1
Enthusiast
Enthusiast

Wev gone old school to get around this problem:

we are calling a .bat file from a .vbs file on logon so its silent and simply installing the printer as follows:

RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n "\\print server\printer name"

the  """"/y"""" statement is what sets default.

RLI2013
Enthusiast
Enthusiast

That is the way to go... Thanx!

Reply
0 Kudos
szilagyic
Hot Shot
Hot Shot

You may also want to check out this KB; it contains a step to disable the mapping of the default printer from the Thin Client, to the VM.

Windows 7 desktops with ThinPrint display only the default printer (1032872)

apelz
Enthusiast
Enthusiast

Hey guys,

I have the same problem on Windows 10 Enterprise 1909 x64 with VMware DEM 9.9.0 with non persistent instant clones. I have already disabled the TP services in the gold image and the default will not remembered. 😞

Is there another solution?

Reply
0 Kudos
apelz
Enthusiast
Enthusiast

Okay I can see that the printers which I had mapped before, appears with a delay. Maybe this is the reason why the default printer is lost.

Reply
0 Kudos
kvmw2130
VMware Employee
VMware Employee

Hello,

Simple solution would be to create a batch file with below content:

cmd.exe /c reg delete "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\SessionDefaultDevices" /f

Then use this batch file on GPO logon script. This should help you...

Reply
0 Kudos
joshuarupp
Contributor
Contributor

So I'm not sure if anyone is still looking but here is what I am using in our production environment and don't have any issues.  When I googled searched I landed her and a few other pages and came up with an alternative solution.  I am already using a simliar method with Get-Printer/Add-Printer for persisting IP mapped printers so that's why I went this way.  I am open to any feedback or questions.  Don't be afraid to reach out.  Ok, so here we go...

I used Dynamic Environment Manager (formerly known as UEM) to create a config file to persist the CSV file by creating a custom config file from the Config File Creation Wizard:

[IncludeFiles]

<LocalAppData>\Microsoft\Windows\defaultprinter.csv

##  You can put file wherever you want to, that's just where I put it.

Then I created 2 .ps1 files

defaultprinterexport.ps1

defaultprinterimport.ps1

I put them into a directory that I created that hast other scripts I use - C:\ProgramData\vdiscripts\

I created a Logon Task with the following:

powershell.exe -ExecutionPolicy Bypass C:\ProgramData\vdiscripts\defaultprinterimport.ps1

I created a Logoff Task with the following:

powershell.exe -ExecutionPolicy Bypass C:\ProgramData\vdiscripts\defaultprinterexport.ps1

Here is what was in each powershell script:

defaultprinterexport.ps1

------------------------

Get-WmiObject -Query " SELECT * FROM Win32_Printer" | Where-Object { $_.Default -like 'True' } | Select-Object Name | Export-CSV "$env:localappdata\Microsoft\Windows\defaultprinter.csv" -NoTypeInformation

defaultprinterimport.ps1

-----------------------

$printer = Import-CSV "$env:localappdata\Microsoft\Windows\defaultprinter.csv"

(New-Object -ComObject WScript.Network).SetDefaultPrinter($printer.Name)

Reply
0 Kudos
derauqs
Contributor
Contributor

This is some great advice.  I really appreciate it.  Unfortunately it looks like for some reason while my log off script is behaving, my log on/import script is not doing anything. 

I have unfortunately stumbled into an environment with a bunch of DNS added devices and no print servers, so I need to figure something out.  I actually did go ahead and set up a print server for a new site and configured point and print to allow users to manage print devices in a limited manner, but no matter what I do, printers do not retain in user profiles.  I've tried everything I could find online for DEM on this, and the printers just disappear.  So instead I used the DEM printer mappings for these devices which work great... except users cannot keep a default printer.  That's what led me to your post.

I feel like no matter what I do with this it's 2 steps forward, 2 steps back and I end up in the same place.

I also set up Location Based Printing, which does actually work nicely, but also doesn't seem to allow users to manage default printers.  It's also not something that I think will scale super well since our subnets aren't organized enough for it, aside from smaller site locations.  I don't really want a 4 story building where users on floor #1 have printers on floor #4 mapped to them.  Of course, our subnets/ip ranges are only really broken down to location/building and nothing more precise, so that's basically how that would work, functionally.

Edit: I also suppose this was post necromancy, sorry about that...

Reply
0 Kudos
Baileyboy
Contributor
Contributor

Did you have any luck with local USB printers? I have tried everything with no luck, after reboot of thin clients our local  USB printers are not remembered.

Reply
0 Kudos