
Powershell을 사용하여 폴더를 압축하려고 하면 C:\Program Files
다음 오류가 발생합니다. 누구든지 도움을 주시면 감사하겠습니다.
명령:
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\\"