嗨,我正在批量构建我自己的防病毒软件,并且想要添加一个压缩炸弹或解压炸弹探测功能,我如何确定批量或vbscript中的zip的最终未压缩大小?提前感谢
发布于 2014-12-30 07:44:55
将其保存为.bat
@if (@x)==(@y) @end /***** jscript comment ******
@echo off
cscript //E:JScript //nologo "%~f0" %*
exit /b 0
@if (@x)==(@y) @end ****** end comment *********/
var wshShell = WScript.CreateObject("WScript.Shell");
var args=WScript.Arguments;
var zipFile=args.Item(0);
getSize = function(path){
var ShellObj=new ActiveXObject("Shell.Application");
var targetObject = new Object;
var targetObject=ShellObj.NameSpace(path);
if (typeof size === 'undefined'){
var size=0;
}
if (targetObject != null ){
for (var i=0; i<targetObject.Items().Count;i++){
//WScript.Echo("Checking: "+targetObject.Items().Item(i));
if(!targetObject.Items().Item(i).IsFolder){
size=size+targetObject.Items().Item(i).Size;
} else if (targetObject.Items().Item(i).Count!=0){
size=size+getSize(targetObject.Items().Item(i).Path);
}
}
} else {
return 0;
}
return size;
}
WScript.Echo(getSize(zipFile));它只使用一个参数- zip文件并以字节打印其大小。( Item.Size属性获得未压缩大小)
编辑它不工作与相对的paths.Full路径应该使用。 zipjs.bat (引入的这里 )可用于此目的:
call zipjs.bat getSize -source C:\\zipFile.zip不再需要完全路径,可以使用相对路径。
https://stackoverflow.com/questions/27700247
复制相似问题