简体   繁体   English

如何在Windows批处理中将文件通过管道传输到加密的,受密码保护的zip文件中,然后删除原始文件?

[英]How do I pipe a file into an encrypted, password protected zip file, then delete the original file, in Windows batch?

I am attempting to export some database data using the BCP Utility. 我正在尝试使用BCP实用程序导出一些数据库数据。

Here is my batch command so far: 到目前为止,这是我的批处理命令:

BCP [table] out [file] -c -T -S [server] -t"¶" | 7z.exe a -si [archive name] -sdel

The BCP part works just fine: BCP部分工作正常:

BCP [table] out [file] -c -T -S [server] -t"¶"

However, for the 7-Zip part: 但是,对于7-Zip部分:

7z.exe a -si [archive name] -sdel

It works to a point. 它工作到一定程度。 The original file is not removed, and I'd also like to encrypt the archive with 128 bit or 256 bit encryption with a password. 原始文件不会被删除,我还想使用密码对128位或256位加密来加密存档。

Any suggestions? 有什么建议么?

I found a work around solution with a small VB .NET script. 我发现了使用小型VB .NET脚本的解决方案。

The script takes in a table name, runs BCP into a text file, runs 7 Zip with encryption options ( https://sevenzip.osdn.jp/chm/cmdline/switches/method.htm#Zip ), and a password, then deletes the original text file. 该脚本采用一个表名,将BCP运行到一个文本文件中,运行带有加密选项的7 Zip( https://sevenzip.osdn.jp/chm/cmdline/switches/method.htm#Zip )和一个密码,然后删除原始文本文件。 These commands are run using the Process() object functions. 这些命令使用Process()对象函数运行。

That way I can loop through the tables I need placed in files easily. 这样,我可以轻松遍历需要放置在文件中的表。

It is not the Windows batch answer I was looking for, but it works. 这不是我一直在寻找的Windows批处理答案,但是它可以工作。

Any other suggestions are still welcome. 仍然欢迎其他任何建议。

Thanks! 谢谢!

BCP .... | 7z u -sidirData -pMyPassword -mhe outputFile.7z
              ^ ^          ^            ^    ^______________ The file that will be generated
              | |          |            |___________________ Encrypt file names
              | |          |________________________________ Password used for encryption
              | |___________________________________________ Name of stored file
              |_____________________________________________ update/create container file

Note that there are no spaces between the switches and the values 请注意,开关和值之间没有空格

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Windows 中使用 PHP 创建受密码保护的 Zip 文件 - Creating a Password Protected Zip File using PHP in Windows 如何访问与批处理文件关联的原始文件名 - How do I access the original file name that is associated a batch file 如何通过Python在Windows中删除(g)zip文件? (在LabVIEW中生成的文件。) - How do I delete a (g)zip file in Windows via Python? (File generated in LabVIEW.) Windows批处理文件 - 管道到FIND - Windows Batch file - pipe to FIND 如果使用Windows批处理文件将文件清空,如何检测(和删除)文件? - How do I Detect (and Delete) a File if it is Empty using a Windows Batch File? 7-Zip 命令在 Windows 上创建和解压缩受密码保护的 ZIP 文件? - 7-Zip command to create and extract a password-protected ZIP file on Windows? 在Windows上以编程方式解压缩AES加密的zip文件 - Programatically unzip an AES encrypted zip file on Windows windows批处理文件到zip然后ftp文件 - windows batch file to zip and then ftp file 如何测试 Zip 文件在 Windows 批处理文件中是否有效 - How to test if a Zip file is valid in a windows batch file 如何使用Windows批处理文件删除不包含某些字符的文件? - How can I Delete Files That Do Not Contain Certain Characters Using Windows Batch File?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM