Forum Discussion
AlexanderM
15 years agoStaff
Hi Carsten,
To unzip an archive from script, you need to run the needed archiver with command-line parameters. After unzipping, you can get the contents of the archive (see the example below that uses the 7-Zip free archiver) and then analyze them.
function Test()
{
var contents = readArchive("C:\\file.zip");
for (i = 0; i < contents.length - 1; i++)
{
Log.Message(contents);
}
}
function readArchive(archive)
{
var folder = extractArchive(archive)
var list = slPacker.GetFileListFromFolder(folder);
var aFile = list.split(chr(13)+chr(10));
aqFileSystem.DeleteFolder(folder, true);
return aFile;
}
function extractArchive(archive)
{
var archiverExecutable = "\"C:\\Program Files (x86)\\7-Zip\\7z.exe\"";
var toFolder = "C:\\temp\\extracted\\";
var cmdLine = archiverExecutable + " x " + archive + " -o" + toFolder;
var WshShell = Sys.OleObject("WScript.Shell")
WshShell.Run(cmdLine, 5, true)
return toFolder;
}
Related Content
Recent Discussions
- 2 hours agoSvetaG