
Tentando compactar uma pasta C:\Program Files
usando o Powershell, porém obtendo o seguinte erro. Agradeço se alguém puder ajudar.
Comando:
powershell.exe -nologo -noprofile -command Compress-Archive -Path "C:\Program Files\avr\cache.dat" -Destinationpath "C:\Program Files\avr\bur\"
Erro:
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
Responder1
Leia e siga powershell /?
(ajuda integrada):
-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.
Usar
powershell.exe -nologo -noprofile -command "& {Compress-Archive -Path 'C:\Program Files\avr\cache.dat' -Destinationpath 'C:\Program Files\avr\bur\'}"
Responder2
A parte Powershell do seu comando será executada como está na interface Powershell. Mas se você executá-lo em um prompt de comando, precisará escapar das aspas com barras invertidas. Assim:
powershell.exe -nologo -noprofile -command Compress-Archive -Path \"C:\Program Files\avr\cache.dat\" -Destinationpath \"C:\Program Files\avr\bur\\"