1. Leif Olsson
  2. PowerBuilder
  3. Wednesday, 4 December 2019 13:41 PM

Scenario:
- In Windows client printer settings "Let Windows manage my default printer" is checked
- Local printers are redirected to remote server
- Our PowerBuilder application starts through RemoteApp

Issue: At first print in a RemoteApp-session PrintGetPrinter() function seems to randomly get a printer (and not the last used in client).
When the user has printed, the PrintGetPrinter() function gets the last used printer. But only in that session.

There are printerfixes in PowerBuilder 2019 regarding Windows server 2016, but those fixes does not resolve this issue.
We have the same problem with runtime for PowerBuilder 2017 R3 and PowerBuilder 2019. We have added the Swedish language pack to the runtime.

I have searched this forum and the Internet. The only suggestions is to turn off setting "Let Windows manage my default printer". Fine with me,
but not accepted by our customers.

I have also seen that Microsoft has changed registry keys that handles default printer (also mentioned in this forum):
[With the release of server-2012 and up (2016, 2019), Microsoft changed
the location of terminal-server default printer from:
"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Terminal Server
Client\DefaultPrinter"
to:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Windows\SessionDefaultDevices\<session>\Device".]

Is this issue a bug in PowerBuilder or is the solution to change some settings on the server or?

/Leif

Leif Olsson Accepted Answer Pending Moderation
  1. Thursday, 5 December 2019 15:28 PM
  2. PowerBuilder
  3. # 1
0
Votes
Undo

Thanks Chris for quick response!

Now I have received answers to your questions from cloud technicians:
1. We use Microsoft's Hyper-V virtualization.
2. Microsoft Windows Server Version 6.3 (Build 9600)

The heading has thus become wrong on this case, since 6.3 is Windows Server 2012 R2. On the other hand, it should be the same conditions as in Windows Server 2016, since the default management of printers is redone from the 2012 version?

Regards
/Leif

Comment
Have you tried using this Unicode Printer declaration MS-Windows API instead, as follows:

FUNCTION Boolean GetDefaultPrinter ( Ref string pszBuffer, Ref ulong pcchBuffer ) Library "winspool.drv" Alias For "GetDefaultPrinterW"



  1. Chris Pollach @Appeon
  2. Thursday, 5 December 2019 15:51 PM
So far we have only used the built-in function in PowerBuilder. We will try your suggestion, but unfortunately it may take some time before we can test it in a cloud and come back with the result.



/Leif
  1. Leif Olsson
  2. Thursday, 5 December 2019 16:09 PM
Conclusions after a number of tests performed by three individuals from different clients via RemoteApp:



1. PowerBuilder function PrintGetPrinter() provides at first call the first printer that is not redirected in the list PrintGetPrinters() provides (and not randomly)? Alternate default printer on the server?



2. After printing, PrintGetPrinter() returns the last used printer in the session. That's because we call PrintSetPrinter() after printing (which I wasn't aware of before).



3. Last used printer in the session updates the last used in the client. Which is because we call PrintSetPrinter() after printing???



4. If printing is done in the client to another printer, this does not update the ongoing RemoteApp session.



5. GetDefaultPrinterW() returns the last used printer in the client before the RemoteApp session started.



6. GetDefaultPrinterW() returns the same printer throughout the RemoteApp session - even after printing to another printer.



7. If a call are made to GetDefaultPrinterW() - without making a print - and then PrintGetPrinter() is called via a parallel RemoteApp session within the same login to the server, the last used printer in the client are returned before the RemoteApp session started.



Note. If "Let Windows manage my default printer" is unchecked, PrintGetPrinter() provides the correct printer in PowerBuilder 2019, but not in 2017 R3 1885.



With reference to point 7, we tried to make a call to GetDefaultPrinterW() in the application's open event. It didn't help. Either it is too early or too late (if there is any caching for PrintGetPrinter()?).



When printing, we list available printers. We make a preselection of the most recently used (or Windows default printer at first print per session). For now we have made an ugly solution:



If the result of PrintGetPrinter() contains the text 'redirected', we assume that it is the most recently used printer.

If the result of PrintGetPrinter() does not contain the text 'redirected', then we call GetDefaultPrinterW(). If that result contains 'redirected' then we take that result as default printer. The solution also works well if you are not running via Terminal Server or RemoteApp. Does not work as well if you run via Terminal Server or RemoteApp and choose a printer that is installed on the server only. We consider that scenario less likely.
  1. Leif Olsson
  2. Thursday, 12 December 2019 12:13 PM
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 4 December 2019 16:01 PM
  2. PowerBuilder
  3. # 2
0
Votes
Undo

Hi Leif;

  Can you tell us ...

1) Is this native MS-Windows or on a VM / Citrix environment?

2) What version & build of MS-Windows?

Regards ... Chris

 

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.