2017-12-19 18 views
-3

폴더에서 동일한 비밀번호를 사용하여 10 개의 파일을 비밀번호로 보호하려고합니다. 완료되면, 나는 동일한 암호로 각각 10 개의 개별 zip 파일을 갖고 싶습니다. 내 스크립트는 다음과 같지만 파일을 아카이브로 열 수 없다는 오류가 발생합니다. 어떤 도움을 크게 감상 할 수7zip과 함께 powershell 사용 - 비밀번호는 폴더의 각 파일을 보호합니다.

Open archive: testfile.pdf 
7z.exe : ERROR: testfile.pdf 
At line:6 char:5 
+  & 'c:\program files\7-zip\7z.exe' a $file1.zip $file1 -p123 
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
+ CategoryInfo   : NotSpecified: (ERROR: testfile.pdf:String) [], RemoteException 
+ FullyQualifiedErrorId : NativeCommandError 
Can not open the file as archive 
System ERROR: 
Incorrect function. 

:

$list=gci "C:\temp\test" 
foreach ($file in $list) 
{ 
    $file1=$file|select -ExpandProperty name 
    & 'c:\program files\7-zip\7z.exe' a $file1.zip $file1 -p123 
} 

은 내가 오류입니다. 감사합니다

답변

-1

오, 소년 ... 오, 내 자신을 알아 냈습니다. 인용 부호가 필요합니다 !!!

& 'c:\program files\7-zip\7z.exe' a "$file1.zip" $file1 -p123