[英]How do I pipe a file into an encrypted, password protected zip file, then delete the original file, in Windows batch?
我正在尝试使用BCP实用程序导出一些数据库数据。
到目前为止,这是我的批处理命令:
BCP [table] out [file] -c -T -S [server] -t"¶" | 7z.exe a -si [archive name] -sdel
BCP部分工作正常:
BCP [table] out [file] -c -T -S [server] -t"¶"
但是,对于7-Zip部分:
7z.exe a -si [archive name] -sdel
它工作到一定程度。 原始文件不会被删除,我还想使用密码对128位或256位加密来加密存档。
有什么建议么?
我发现了使用小型VB .NET脚本的解决方案。
该脚本采用一个表名,将BCP运行到一个文本文件中,运行带有加密选项的7 Zip( https://sevenzip.osdn.jp/chm/cmdline/switches/method.htm#Zip )和一个密码,然后删除原始文本文件。 这些命令使用Process()对象函数运行。
这样,我可以轻松遍历需要放置在文件中的表。
这不是我一直在寻找的Windows批处理答案,但是它可以工作。
仍然欢迎其他任何建议。
谢谢!
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
请注意,开关和值之间没有空格
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.