powershell - Powershell打印Word文档

标签 powershell

我有一个.txt文档和一个MS Word .doc,我想发送给打印机。对于.txt文件,运行Powershell Start-Process -FilePath C:\Temp\Versions.TXT -Verb print可以正常工作。

但是,当我使用Powershell命令Start-Process -FilePath C:\Temp\Versions.docx -Verb print时,出现以下错误。

Start-Process : A positional parameter cannot be found that accepts argument 'version'.
At line:1 char:14
+ Start-Process <<<<  -FilePath C:\Temp\Versions.docx -Verb print
    + CategoryInfo          : InvalidArgument: (:) [Start-Process], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.StartProcessCommand

怎么了?有人可以帮忙吗?

最佳答案

问题不是-Verb Print
花点时间阅读错误消息:

Start-Process : A positional parameter cannot be found that accepts argument 'version'.

它说,未找到接受version的参数

您的代码行中只有一个单词“Version”,即Versions.TXT
请尝试以下操作:
Start-Process -FilePath "C:\Temp\Versions.TXT" -Verb print

关于powershell - Powershell打印Word文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16489028/

相关文章:

powershell - 使用传递和获取值的 PowerShell 函数

debugging - 无法通过 Visual Studio 调试 PowerShell

python - python子进程如何尊重powershell退出代码?

java - 如何从 PowerShell 调用 Java 程序?

Powershell Dynamics CRM,如何向用户添加两个队列

sharepoint - 在 C# 中运行 powershell 命令

powershell - 列出所有先前加载的 PowerShell 变量

powershell - 如何输出到日志文件

arrays - powershell 返回 1 个单个元素而不是数组

powershell - 在 powershell 中重命名文件名的一部分