无法在 Powershell 中 运行 7-Zip

Unable to run 7-Zip in Powershell

这是在关于 another question 的讨论中提出的 我在 运行ning 可执行文件中询问 Windows Powershell

每当我 运行 7z 在装有 PS 2.0 的工作机器上时,我都会收到此错误

Bad numeric constant: 7.
At line;1 char:2
+ 7 <<<< z
    + CategoryInfo          : ParserError: <7:String> [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : BadNumericConstant.

请注意,即使我给出完整的文件名 7z.exe,也会出现此错误。但是,如果我通过输入 cmd 进入命令行模式,它可以正常工作。

如有任何帮助,我们将不胜感激。

试试这个:

& "Path\toz.exe" arg1 arg2 etc

听起来 PowerShell 正试图将您的 [String] 按字面解释为 [Int]