- //&cls&cscript -nologo -e:jscript "%~f0"&pause&exit
- function GetSize(val)
- {
- var s ='';
- if(val >= 1125899906842624)
- s = parseInt((val/1125899906842624)*100)/100+' PB';
- else if(val >= 1099511627776)
- s = parseInt((val/1099511627776)*100)/100+' TB';
- else if (val >= 1073741824)
- s = parseInt((val/1073741824)*100)/100+' GB';
- else if (val >= 1048576)
- s = parseInt((val/1048576)*100)/100+' MB';
- else if (val >= 1024)
- s = parseInt((val/1024)*100)/100+' KB';
- else s = val+' 字节';
- return s;
- }
-
- var fso = new ActiveXObject('Scripting.FileSystemObject');
- var enu = new Enumerator(fso.Drives);
- var str = '';
- var head = '盘符 类型 总容量 已用容量 剩余容量 使用率 文件系统\r\n'+
- '--------------------------------------------------------------';
- for (; !enu.atEnd(); enu.moveNext())
- {
- var drive = enu.item();
- if (drive.isReady)
- {
- var type = '';
- var UsedSpace = drive.TotalSize-drive.FreeSpace;
- switch(drive.DriveType)
- {
- case 0:type = 'Unknown';break;
- case 1:type = 'Removable';break;
- case 2:type = 'Fixed';break;
- case 3:type = 'Network';break;
- case 4:type = 'CD-ROM';break;
- case 5:type = 'RAM disk';break;
- default:type = 'Unknown';
- }
- str += drive.DriveLetter+' '+type+' '+
- GetSize(drive.TotalSize)+' '+
- GetSize(UsedSpace)+' '+
- GetSize(drive.FreeSpace)+' '+
- parseInt(UsedSpace/drive.TotalSize*100)+'% '+
- drive.FileSystem+'\r\n';
- }
- }
- WSH.echo(head+'\r\n'+str);
复制代码
|