A standard implementation of this technique is provided at: https://learn.microsoft.com/en-us/troubleshoot/windows-client/printing/add-print-directory-feature
Unfortunately it does not work for me. The Printdir.bat file is:
@echo off
dir %1 /-p /o:gn > "%temp%\Listing"
start /w notepad /p "%temp%\Listing"
del "%temp%\Listing"
exit
My implementation fails at the cmd level with the error:
The filename, directory name, or volume label syntax is incorrect". (The program continues and results in no file created since nothing is passed to notepad).
If run in the Windows directory, it runs fine.
Adding quotes around "%1"
did not help and neither did "%~1"