【问题标题】:Add Print Directory Feature to Windows Explorer Does Not Work将打印目录功能添加到 Windows 资源管理器不起作用
【发布时间】:2021-08-12 07:03:38
【问题描述】:

此技术的标准实现在:https://docs.microsoft.com/en-us/troubleshoot/windows-client/printing/add-print-directory-feature

不幸的是,它对我不起作用。 Printdir.bat 文件是:

@echo off 
dir %1 /-p /o:gn > "%temp%\Listing" 
start /w notepad /p "%temp%\Listing"
del "%temp%\Listing"
exit

我的实现在 cmd 级别失败并出现错误:

文件名、目录名或卷标语法不正确”。 (程序继续执行,结果没有创建任何文件,因为没有向记事本传递任何内容)。

如果在 Windows 目录下运行,它运行良好。 在"%1" 周围添加引号没有帮助,"%~1" 也没有

【问题讨论】:

  • 删除 @echo off 并将 exit 替换为 pause,然后在命令提示符窗口中查看 %1 扩展为...
  • 也应该将start /w notepad替换为%SystemRoot%\notepad.exe
  • 我得到的是:\"C:\Users\Roger\Documents|自定义 Office 模板\"
  • 我得到的是:C:WINDOWS\system32>dir \"C:\Users\Roger\Documents\Custom Office Templates\" /-p /o:gn 1>"C:\Users \Roger\AppData\Local\Temp\Listing" 则报错文件名、目录名或卷标语法不正确。那是我试图打印的目录。
  • 看来问题是dir之后的\。也就是说, dir \"C:\Users\.... 应该是 dir "C:\Users\.... 但是,我不知道它来自哪里以及如何修复它。

标签: batch-file cmd windows-10 regedit


【解决方案1】:

说明(在多个站点重复)创建了一个文件 PrintDirectoryListing.reg,其中第 3 步和第 6 步创建了一个命令 Printdir.bat \"%1\" 从 aschipfl 和 Mofi 的 cmets 中,我能够对活动进行故障排除并编辑注册表,消除 "%1" 之前的 \,使两个命令 Printdir.bat "%1\"。 现在一切正常。再次感谢 aschipfl 和 Mofi

【讨论】:

    猜你喜欢
    • 2012-04-10
    • 2011-09-22
    • 1970-01-01
    • 2011-07-29
    • 1970-01-01
    • 2012-01-07
    • 1970-01-01
    • 1970-01-01
    • 2012-09-21
    相关资源
    最近更新 更多