Search code examples
batch-filecmdwindows-10regedit

Add Print Directory Feature to Windows Explorer Does Not Work


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"


Solution

  • The instructions (repeated at several sites) created a file PrintDirectoryListing.reg with steps 3 and 6 creating a command Printdir.bat \"%1\" From the comments by aschipfl and Mofi, I was able to troubleshoot the activity and edit the registry, eliminate the \ before "%1" making both commands Printdir.bat "%1\". Now everything works properly. Thanks again to aschipfl and Mofi