尝试C:\Program Files
使用 Powershell 压缩文件夹,但出现以下错误。如果有人能提供帮助,我将不胜感激。
命令:
powershell.exe -nologo -noprofile -command Compress-Archive -Path "C:\Program Files\avr\cache.dat" -Destinationpath "C:\Program Files\avr\bur\"
错误:
Compress-Archive : A positional parameter cannot be found that accepts argument 'Files\avr\cache.dat'. At line:1 char:1 + Compress-Archive -Path C:\Program Files\avr\cache.dat -Destina ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Compress-Archive], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Compress-Archive
答案1
阅读并关注powershell /?
(内置帮助):
-Command
…
To write a string that runs a Windows PowerShell command, use the format:
"& {<command>}"
where the quotation marks indicate a string and the invoke operator (&)
causes the command to be executed.
使用
powershell.exe -nologo -noprofile -command "& {Compress-Archive -Path 'C:\Program Files\avr\cache.dat' -Destinationpath 'C:\Program Files\avr\bur\'}"
答案2
命令的 Powershell 部分将在 Powershell 界面中按原样运行。但是,如果您从命令提示符运行它,则需要使用反斜杠转义引号。如下所示:
powershell.exe -nologo -noprofile -command Compress-Archive -Path \"C:\Program Files\avr\cache.dat\" -Destinationpath \"C:\Program Files\avr\bur\\"