TextPad – Strange Printing Behavior

I’ve been tasked with resolving an issue that involves printing (my favorite /s).

A console application used in Windows 10 and Windows 11 is not printing certain files when it should.

Printing is handled by TextPad using the -p command line parameter and passed a filename.

To reproduce the issue, I found the file that is not printing which is named PRNOUT.P12. I attempted to call TextPad from the command line with the -p parameter and pass the PRNOUT.P12 file to see what, if anything, happens. The print dialog comes up, queues, and goes away. This is printing to the default printer, a Brother MFC-L1727DW laser over wifi connection (*grumble*). Nothing prints.

If I change the default printer to Microsoft Print to PDF printer, it will prompt to save the file when attempting to print the file from the command line via TextPad.

If I change the default printer back to the Brother printer, it looks like it prints, but it doesn’t do anything on the machine.

Short of a TCPdump to see if anything was actually being sent to the printer, I decided to run a few other tests.

I made a copy of PRNOUT.P12 and named it PRNOUT.P12.copy and passed the new file to TextPad to print. It printed to the Brother printer just fine.

I created a test file (echo test > TEST.P12) and sent it to TextPad command line printer; it printed just fine to the Brother.

I know a P12 file in Windows contains a cryptographic certificate for PKCS#12 – so maybe Windows is filtering this somehow, or maybe the printer is doing something with this file when it is sent to the queue. I think it’s important to mention that the printer is added as a TCP/IP printer.

I decided to update the firmware on the printer, update Windows and reboot everything.

Tested everything again; failure to print the PRNOUT.P12 file. It fails to print any file ending in .P12 to the Brother printer.

Another important note. If I open the PRNOUT.P12 file, or any P12 created test file directly in TextPad and then print from the File menu, it prints just fine.

Another note. If I use notepad /p PRNOUT.P12 it prints just fine as well. I can’t use this method because the console application specifically calls textpad.exe -p <filename>.

I’m at a loss here and have tested both TextPad 7.x and TextPad 8.x to no avail.

I’m pointing my finger at TextPad. But why did this problem just start? I’ve also disabled any security suite on the system as a test measure.

Tests Performed: Printing to Brother MFC-L2717DW

FAIL: textpad.exe -p PRNOUT.P12

SUCCESS: textpad.exe -p PRNOUT.P12.copy

FAIL: textpad.exe -p test.P12

SUCCESS: notepad.exe /p PRNOUT.P12

Tests Performed: Printing to Microsoft Print to PDF

Success: textpad.exe -p PRNOUT.P12

Tests Performed: Opening File and Printing

Success: textpad.exe File > Open > PRNOUT.P12; File > Print

Workaround

Since I’ve found that a batch file handles some of this, I’ve modified the batch file to change the name of the file to then pass it to the printer and it is working. The binary is a Watcom C/C++ that I’ve been trying to get through to make a more permanent change but haven’t had much luck as of this writing.

Here’s what the batch file looks like.

tpad.bat

Original:

c:\progra~2\textpa~1\textpad.exe %1 %2

Modified:

@echo off
setlocal

set _filename=%~n2
set _extension=%~x2

IF /I "%_extension%" == ".P12" (
type %2 > %_filename%.P12.tmp
c:\progra~2\textpa~1\textpad.exe -p %_filename%.P12.tmp
) ELSE (
c:\progra~2\textpa~1\textpad.exe %1 %2
)

Hide Application from Add/Remove Programs

One way to hide an application from Add/Remove programs is by settings a SystemComponent registry key for the application in the Uninstall path.

For 32-bit applications, the Uninstall path can be found at:

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall

For 64-bit applications, the Uninstall path can be found at:

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

Inside the Uninstall path, find the application you want to hide. Once selected, add a new DWORD 32bit named SystemComponent and set the value to 1.

Show mapped drives of user from elevated command prompts

When you run an elevated command prompt as administrator, the mapped drives are unavailable in the elevated command prompt.

This issue also affects other applications that run in an elevated context (run as administrator) and use drive letters to access mapped drives.

When UAC is enabled, the system creates two logon sessions at user logon. Both logon sessions are linked to one another. One session represents the user during an elevated session, and the other session where you run under least user rights.

When drive mappings are created, the system creates symbolic link objects (DosDevices) that associate the drive letters to the UNC paths. These objects are specific for a logon session and are not shared between logon sessions.

The EnableLinkedConnections registry entry forces the symbolic links to be written to both linked logon sessions that are created, when UAC is enabled.

When the UAC policy is configured to Prompt for credentials, a new logon session is created in addition to the existing two linked logon sessions. Previously created symbolic links that represent the drive mappings will be unavailable in the new logon session.

Group Policy

  1. In Local Group Policy Editor, locate the following Group Policy path:
    Local Computer Policy\Windows Settings\Security Settings\Local Policies\Security Options
  2. Configure the following policy to Prompt for consentUser Account Control: Behavior of the elevation prompt for administrators in Admin Approval Mode

Registry

  1. In Registry Editor, locate and then click the following registry subkey:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
  2. Right-click Configuration, select New, and then select DWORD (32-bit) Value.
  3. Name the new registry entry as EnableLinkedConnections.
  4. Double-click the EnableLinkedConnections registry entry.
  5. In the Edit DWORD Value dialog box, type 1 in the Value data field, and then select OK.
  6. Exit Registry Editor, and then restart the computer.

You can use REG ADD to add the registry value via an elevated command line:

reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLinkedConnections /t REG_DWORD /d 1 /f

Block Windows 11 Update

The easiest way to block the Windows 11 update on a Windows 10 system is by adding a policy via the Registry.

In HKEY_LOCAL_MACHINE, navigate to SOFTWARE\Policies\Microsoft\Windows

Create a new Key named WindowsUpdate

Add the following items in the WindowsUpdate key:

  • REG_DWORD named TargetReleaseVersion with a value of 1
  • REG_SZ named TargetReleaseVersionInfo with a value of 21H2
  • REG_SZ named ProductVersion with a value of Windows 10

Below is a registry file example. You can also download a copy if you’d like.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate]
"TargetReleaseVersion"=dword:00000001
"TargetReleaseVersionInfo"="21H2"
"ProductVersion"="Windows 10"

If you are using ManageEngine’s Desktop Central, you can create a configuration to deploy to computers with the Desktop Central agent. Here’s an example of the configuration in the Manage Engine Desktop Central web administration panel.

Windows 11 Installation: Bypass TPM and Secure Boot Requirements During Installation

Windows 11 introduced new system requirements for the operating system. Two of these requirement checks, TPM 2.0 and Secure Boot, can be bypassed during installation from a bootable ISO.

To bypass the TPM 2.0 or Secure Boot check(s) while in the installation screen, press SHIFT + F10 and a command window will open.

Bypass TPM 2.0 Check

REG ADD HKLM\SYSTEM\Setup\LabConfig /v BypassTPMCheck /t REG_DWORD /d 1

Bypass Secure Boot Check

REG ADD HKLM\SYSTEM\Setup\LabConfig /v BypassSecureBootCheck /t REG_DWORD /d 1

Close the command window and click back on the installation screen to go back one and then click to continue the installation.