For Posterity,
With regards to using a Powerbuilder Application in Citrix and the Default Printer.
Afaict...
Custom Code
We have implemented custom code in a timer to check the operating system default printer (windows api call) for 1 minute (configurable) of startup, and to update the powerbuilder default printer to match.
With an extra checks that the user has not already used "PrintSetup()" to explicitly select a printer.
This seems to work for this application well (so far in testing) and solves the problems we had run into.
Using pb.ini with "[Application] Citrix=1"
This has it's merits, but drawbacks as well.
If user prints before using "PrintSetup()", the PowerBuilder default printer is the last one in the list - not the users default printer. Consequently, it is required that the users use "PrintSetup()" at least once before any printing.
Every time the user uses "PrintSetup()", the selected printer resets to the operating systems current default printer - not the last printer the user most recently selected.
We are not using this setting due to these drawbacks.
Using user the citrix policy setting "Wait for printers to be created" before starting the application
We did NOT user the citrix setting "Wait for printers to be created".
https://docs.citrix.com/en-us/citrix-virtual-apps-desktops/policies/reference/ica-policy-settings/printing-policy-settings.html#wait-for-printers-to-be-created
This setting will delay starting the application until all the printers have become available in the citrix environment. It seems like an option perfect for PowerBuilders problem in this area.
Our citrix admins recommended against it - they don't use it for any other applications in this organisation or in prior organisations they've worked for.
They warned that some users may have printers that malfunction resulting in long delay to startup, or even complete failure, and also the problem is difficult to troubleshoot.
We tried it, and it added 10 seconds to startup for a sample of users, but we can't easily say for all users the impact (other than turning it on in production, as seeing the fallout).
Still it looks like a good option if custom code is unviable, and supporting users with citrix printer creation problems is viable.
It is a fallback option we could use if we run into further problems.
Thanks again for the community, as least I found out there was no well known obvious solution.
Cheers!
I tried using pb.ini with "[Application] Citrix=1" with PowerBuilder 2021 GA (build 1311) in Citrix (on Windows Server 2016).
1. If the user prints (a window, or a RTE, for example) without ever opening the "PrintSetup()", then the application still prints using the "last printer in the printer list", instead of the default printer that the local computer/citrix have set.
2. Every time the user opens the "PrintSetup()" (available in the applications menu, for this application), the selected printer reverts back to the default printer that the local computer/citrix have set, rather than the printer selected by the user when they last used "PrintSetup()".
Or due to not using the settings correctly?
Is there a way to have the correct printer (as per the local computer/citrix setting) set automatically, without having the user execute "PrintSetup()" prior to the first time of any printing?
Cheers, Peter.
P.S. Our citrix environment is siloed off from me, so it is hard to do experiments, sorry.