[英]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.