WScript.Echo(getdrivesize("c:", 1, 2) + " Bytes"); WScript.Echo(getdrivesize("c:", 2, 2) + " KB"); WScript.Echo(getdrivesize("c:", 3, 2) + " MB"); WScript.Echo(getdrivesize("c:", 4, 2) + " GB"); // ------------------------------------------- function getdrivesize(sdrive, iformat, iround) { var vdrivesize; var bobjectcreate = false; if (ofso == null) { var ofso = new ActiveXObject("scripting.filesystemobject"); bobjectcreate = true; } if (ofso.driveexists(sdrive)) { switch (iformat) { case 1 : vdrivesize = round(ofso.getdrive(sdrive).freespace,iround); break; case 2 : vdrivesize = round((ofso.getdrive(sdrive).freespace/1024),iround); break; case 3 : vdrivesize = round(((ofso.getdrive(sdrive).freespace/1024)/1024),iround); break; case 4 : vdrivesize = round((((ofso.getdrive(sdrive).freespace/1024)/1024)/1024),iround); } } else { if (ofso && bobjectcreate) { ofso = null; } return -1; } if (ofso && bobjectcreate) { ofso = null; } return vdrivesize; } // --------------------- function round(num, dec) { var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec); return result; }