PowerShell 技能连载 - 批量打印 Word 文档

这行代码将在您的配置文件中查找所有 Word 文档:

1
Get-ChildItem -Path $home -Filter *.doc* -Recurse

If you’d like, you can easily print them all. Here is how:
如果需要,可以将它们全部打印出来。以下是具体方法:

1
2
3
4
Get-ChildItem -Path $home -Filter *.doc* -Recurse |
ForEach-Object {
Start-Process -FilePath $_.FullName -Verb Print -Wait
}

它最重要的部分是 -Wait 参数:如果缺少了它,PowerShell 将会同时启动多个 Word 的实例,并行打印所有文档。这将耗尽您系统的资源。使用 -Wait 参数以后,PowerShell 将等待前一个 Word 打印完之后再启动下一个实例。

PowerShell 技能连载 - 批量打印 Word 文档

http://blog.vichamp.com/2017/05/05/bulk-printing-word-documents/

作者

吴波

发布于

2017-05-05

更新于

2022-07-06

许可协议

评论