使用批处理文件压缩和密码保护文件 - 请在此代码中缺少什么

时间:2015-11-04 12:55:13

标签: batch-file winzip

  @echo off
    pushd "S:\SourcePath"
    "c:\program files\winzip\wzzip.exe" -a "S:\Destination\Sample.zip" *.txt  
    popd 

我想我在这段代码中缺少一个用密码加密的额外行。

我在发布之前添加了-s选项,但它只是落在了

  @echo off
    pushd "S:\SourcePath"
    "c:\program files\winzip\wzzip.exe" -a "S:\Destination\Sample.zip" -spassword *.txt  
    popd

1 个答案:

答案 0 :(得分:0)

不确定你做错了什么。我假设你是某种模糊的例子。

Zipfiles.bat

@echo off
pushd "S:\SourcePath"
"c:\program files\winzip\wzzip.exe" -a "S:\Destination\Sample.zip" -spassword *.txt  
popd 

我的输出从命令行运行。

C:\BatchFiles\zip>dir s:\sourcepath\*.* /b
file1.txt
file2.txt
file3.txt

C:\BatchFiles\zip>zipfiles.bat
WinZip(R) Command Line Support Add-On Version 4.0 64-bit (Build 10562)
Copyright (c) 1991-2013 WinZip International LLC - All Rights Reserved


Adding file1.txt
Adding file2.txt
Adding file3.txt
Total bytes=21, Compressed=63 -> -199 percent savings.

Copying Zip file "S:\Destination\Sample.zip".


C:\BatchFiles\zip>dir s:\destination\*.* /b
Sample.zip

C:\BatchFiles\zip>cd /D S:\Destination

S:\Destination>"C:\program files\winzip\wzunzip.exe" -spassword Sample.zip
WinZip(R) Command Line Support Add-On Version 4.0 64-bit (Build 10562)
Copyright (c) 1991-2013 WinZip International LLC - All Rights Reserved

Zip file: Sample.zip


Extracting file1.txt
Extracting file2.txt
Extracting file3.txt

S:\Destination>dir /b
file1.txt
file2.txt
file3.txt
Sample.zip

S:\Destination>