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