Author | Topic: Remote Desktop Printing | |
---|---|---|
Scott Krise | Remote Desktop Printing on Tue, 12 Oct 2021 12:06:35 -0400 Hi Everyone, I've posted this question before, and I wanted to re-post to see if anyone else is having the problem. I have issues at a number of different sites now where if you share your local resources in RDP and let your local printers redirect, that my xbase apps don’t return the proper default printer. The user is then forced to manually pick their printer each time they want to print anything. My fix has been to remove the resource share of printers through RDP and manually install the shared client printer on the server and set that as their default. Is anyone else seeing this type of behavior? My fix has been working pretty well, but now there is some sort of other error (not sure if it’s an rdp problem or a microsoft problem at this point) where the shared printers on servers just are not longer able to be connected to. When you try to connect to them, you just get a message saying "operation cannot be completed". Thanks, Scott | |
Itai Ben-Artzi | Re: Remote Desktop Printing on Tue, 12 Oct 2021 16:43:14 -0700 Scott, Effective Server-2012, the location of the default printer in the register has been changed. Unfortunately, old software such as xBase++ and Crystal Reports are still reading the default printer from the old location. You may update the default printer at the startup of your application as follow: ******************************* Static Procedure Server2016() fix redirected printer in server-2016 Read the default redirected printer from last session in Current_User and write to Window into the Current_User copy of the register. ///////////////////////////////////////////////////////////////////////// MemVar Default_Local_Printer LOCAL cDefaultPrinter, cOS, aSession, cLastSession Local oRegOS, oReg, oReg1, oReg2, xTemp * sleep(50) enough time for the OS to creatd the current user node in the register * oRegOS := XbpReg():NEW( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" ) If ! oRegOS:Status() oRegOS:Create() EndIF cOS := oRegOS:GetValue( "ProductName" ) check if Server-2016 if !Empty(cOS) .and. (at('Windows Server 2016', cOS) > 0 .or. at('Windows Server 2019', cOS) > 0) oReg1 := XbpReg():NEW( "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\SessionDefaultDevices" ) If ! oReg1:Status() oReg1:Create() EndIF aSession := oReg1:KeyList() if !Empty(aSession) cLastSession := "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\SessionDefaultDevices\" + aSession[len(aSession)] in case a user logon multiple times oReg2 := XbpReg():NEW( cLastSession ) If ! oReg2:Status() oReg2:Create() EndIF cDefaultPrinter := oReg2:GetValue( "Device" ) Get default redirected printer if !empty(cDefaultPrinter) .and. at('(redirected', cDefaultPrinter) > 1 only if redirected printer Default_Local_Printer := cDefaultPrinter * oReg := XbpReg():NEW( "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows" ) update Devuce key If ! oReg:Status() oReg:Create() EndIF oReg:SetValue( "Device", cDefaultPrinter ) * oReg := XbpReg():NEW( "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Terminal Server Client\DefaultPrinter" ) update the store If ! oReg:Status() oReg:Create() EndIF oReg:SetValue( "DefaultPrinterStore", cDefaultPrinter ) elseif !empty(cDefaultPrinter) xTemp := dtoc(Date())+' '+Time()+': ' xTemp += 'Default Printer: ' + alltrim(cDefaultPrinter) SaveToFile( xTemp, 'DefaultPrinter.txt' ) else xTemp := dtoc(Date())+' '+Time()+': ' xTemp += 'Default Printer is empty!' SaveToFile( xTemp, 'DefaultPrinter.txt' ) endif endif else xTemp := dtoc(Date())+' '+Time()+': ' xTemp += 'Invalid Operating System!' SaveToFile( xTemp, 'DefaultPrinter.txt' ) endif Return ************* | |
James Loughner | Re: Remote Desktop Printing on Fri, 15 Oct 2021 13:28:46 -0400 Hmmm what XbpReg() the one I have is not the same it is from Thomas Braun and the structures do not match Also no SaveToFile function but that is an easy work arounf. Jim On 10/12/21 7:43 PM, Itai Ben-Artzi wrote: > Scott, > Effective Server-2012, the location of the default printer in the > register has been changed. Unfortunately, old software such as > xBase++ and Crystal Reports are still reading the default printer from > the old location. > You may update the default printer at the startup of your application > as follow: > ******************************* > Static Procedure Server2016() > fix redirected printer in server-2016 > Read the default redirected printer from last session in > Current_User > and write to Window into the Current_User copy of the register. > ///////////////////////////////////////////////////////////////////////// > MemVar Default_Local_Printer > > LOCAL cDefaultPrinter, cOS, aSession, cLastSession > Local oRegOS, oReg, oReg1, oReg2, xTemp > * > sleep(50) enough time for the OS to creatd the current user node in > the register > * > oRegOS := XbpReg():NEW( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows > NT\CurrentVersion" ) > If ! oRegOS:Status() > oRegOS:Create() > EndIF > cOS := oRegOS:GetValue( "ProductName" ) check if Server-2016 > if !Empty(cOS) .and. (at('Windows Server 2016', cOS) > 0 .or. > at('Windows Server 2019', cOS) > 0) > oReg1 := XbpReg():NEW( "HKEY_CURRENT_USER\Software\Microsoft\Windows > NT\CurrentVersion\Windows\SessionDefaultDevices" ) > If ! oReg1:Status() > oReg1:Create() > EndIF > aSession := oReg1:KeyList() > if !Empty(aSession) > cLastSession := "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows > NT\CurrentVersion\Windows\SessionDefaultDevices\" + > aSession[len(aSession)] in case a user logon multiple times > oReg2 := XbpReg():NEW( cLastSession ) > If ! oReg2:Status() > oReg2:Create() > EndIF > cDefaultPrinter := oReg2:GetValue( "Device" ) Get default > redirected printer > if !empty(cDefaultPrinter) .and. at('(redirected', > cDefaultPrinter) > 1 only if redirected printer > Default_Local_Printer := cDefaultPrinter > * > oReg := XbpReg():NEW( > "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows > NT\CurrentVersion\Windows" ) update Devuce key > If ! oReg:Status() > oReg:Create() > EndIF > oReg:SetValue( "Device", cDefaultPrinter ) > * > oReg := XbpReg():NEW( > "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Terminal Server > Client\DefaultPrinter" ) update the store > If ! oReg:Status() > oReg:Create() > EndIF > oReg:SetValue( "DefaultPrinterStore", cDefaultPrinter ) > elseif !empty(cDefaultPrinter) > xTemp := dtoc(Date())+' '+Time()+': ' > xTemp += 'Default Printer: ' + alltrim(cDefaultPrinter) > SaveToFile( xTemp, 'DefaultPrinter.txt' ) > else > xTemp := dtoc(Date())+' '+Time()+': ' > xTemp += 'Default Printer is empty!' > SaveToFile( xTemp, 'DefaultPrinter.txt' ) > endif > endif > else > xTemp := dtoc(Date())+' '+Time()+': ' > xTemp += 'Invalid Operating System!' > SaveToFile( xTemp, 'DefaultPrinter.txt' ) > endif > Return > ************* > |