我有代码创建zip文件夹下面的代码正在用于压缩文件
$ZipArchive = @ScriptDir & "\test.zip"; Put here the full path and name ame of archive you would like to create
$AddFile = @ScriptDir & "\zip.au3"; Put here the the File you would like to compress in the zip
$AddFile2 = "c:\config.sys"; Take another File ...
$ oShell = ObjCreate(“Shell.Application”);创建shell对象
if IsObj($oShell) then
InitZip($ZipArchive); Create an emtpy zip file with header
$oDir = $oShell.NameSpace($ZipArchive); Use the zip file as an "Folder"
$oDir.CopyHere ($AddFile); Copy a file in the "Zip Folder"
$oDir.CopyHere ($AddFile2); Copy a second file
sleep (500); Give the Objekt a litte bit time to work
else
Msgbox (0,"Error","Error creating Object.")
endif
Func InitZip ($zip_path_name)
$init_zipString= Chr(80) & Chr(75) & Chr(5) & Chr(6);Create the Header String
for $n =1 to 18;the
$init_zipString= $init_zipString & Chr(0);Header
next
$file =FileOpen($zip_path_name,2)
FileWrite($file,$init_zipString);Write the string in a file
FileClose($file)
EndFunc
答案 0 :(得分:0)
我建议使用例如 7z通过Run 命令。
将一个文件夹压缩到存档中的命令如下所示:
7z a -r archive.7z directory
在 AutoIt 中,这将是
local $command = "7z a -r archive.7z directory"
Run(@ComSpec & " /c " & $command, @ScriptDir)
如果7z目录未包含在全局路径变量中,您可能还需要指定7z可执行文件的路径。