是否可以将带有批处理文件的文件发送到打印机? [英] Is it possible to send a file to a printer with a batch file?
本文介绍了是否可以将带有批处理文件的文件发送到打印机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用批处理文件将文本文件或.doc或类似文件发送到通过USB端口插入计算机的打印机?
How can I use a batch file to send a text file or a .doc or similar, to a printer plugged into the computer through a USB port?
推荐答案
还要获取打印机名称:
wmic printer get name /value | findstr Name
它将列出所有打印机,例如:
It will list all printers like:
Name=PDF
Name=Microsoft XPS Document Writer
Name=Fax
如果您知道名称的一部分,则可以使用FOR
动态地将其包含在变量中.
And if you know part of the name, you may include it in a variable dynamically with FOR
.
@echo off
for /f "tokens=2 delims==" %%a in (
'wmic printer get name /value ^| findstr PartOfThePrinterName'
) do (
set "printer_name=%%a"
)
REM Also you can remove the FOR command if you want to set the variable as static.
REM ie. "set printer_name=MyPrinterName"
print filename.txt /D:"%printer_name%"
exit /b 0
请注意双引号,并且在/D:
之后不能有空格,以确保它可以使用正确的打印机.
note the double quotes and no white space after /D:
to be sure it get the right printer.
另一种方法是设置默认打印机并通过记事本打印文档.
Another method is to set the default printer and print the document through the notepad.
RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n "%printer_name%"
start /min notepad /P filename.txt
这篇关于是否可以将带有批处理文件的文件发送到打印机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文