
Пытаюсь сжать папку в 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\\"