One of our published apps that used the Crystal Report 8.5 runtime wasn't working properly. The app crashed every time we tried to print something from one of the built-in reports. In troubleshooting this issue we discovered that the default printer is stored in the registry HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device and we found that this registry setting isn't being set if the app is launched as a published app. However, if we launch an interactive desktop session via RDP to the Citrix server the registry key does get set properly. Once this registry key is created and set properly the Crystal Report 8.5 runtime works perfectly and the app prints just fine. Does anyone know why the default printer registry key isn't being set by Server 2016 when we launch a XenApp 7.15 published app?
So we've found what appears to be a bug with Windows Server 2016 and XenApp 7.15 that causes this registry key to not be set if the user launches a published app but it is set if a user logs into a desktop session on the server. To temporarily resolve this issue we've written a Powershell script to set this registry key based on the current default printer when the user signs on and we launch the Powershell script as part of the Published app's startup. We also turn on WaitForPrinterCreation for the published app so that all client printers are created and the default session printer is created by the time the startup script for the published app runs.
Question
Wendell Pinegar
One of our published apps that used the Crystal Report 8.5 runtime wasn't working properly. The app crashed every time we tried to print something from one of the built-in reports. In troubleshooting this issue we discovered that the default printer is stored in the registry HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device and we found that this registry setting isn't being set if the app is launched as a published app. However, if we launch an interactive desktop session via RDP to the Citrix server the registry key does get set properly. Once this registry key is created and set properly the Crystal Report 8.5 runtime works perfectly and the app prints just fine. Does anyone know why the default printer registry key isn't being set by Server 2016 when we launch a XenApp 7.15 published app?
So we've found what appears to be a bug with Windows Server 2016 and XenApp 7.15 that causes this registry key to not be set if the user launches a published app but it is set if a user logs into a desktop session on the server. To temporarily resolve this issue we've written a Powershell script to set this registry key based on the current default printer when the user signs on and we launch the Powershell script as part of the Published app's startup. We also turn on WaitForPrinterCreation for the published app so that all client printers are created and the default session printer is created by the time the startup script for the published app runs.
Set-BrokerApplication APPNAME -WaitForPrinterCreation:1
# Clear any existing errors. # "Waiting for printers to be created" #Start-Sleep 5 $error.clear() $registrykey = "Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows" # Set the location # Set-Location -Path $registrykey -ErrorAction SilentlyContinue # Retrieve the default printer properties. # $wmiDefaultPrinter = Get-WmiObject -query "SELECT * FROM WIN32_PRINTER WHERE Default = TRUE" # If the default printer exists then set the registry values. # if ($wmiDefaultPrinter -ne $null) { "Setting the Windows default printer registry key" Set-ItemProperty -Path $registrykey -Name "Device" -Value ($wmiDefaultPrinter.Name+",winspool,Ne00:") Write-Host "Your default printer is" $wmiDefaultPrinter.Name } else { Set-ItemProperty -Path $registrykey -Name "Device" -Value "Microsoft Print to PDF,winspool,Ne01:" }
Link to comment
31 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now