24-3 ????碟???

YnܬY@ӸƧjpAiHϥΡAdҦpUG

lɡ]dirSize01.js^G]ǦϰUYi^
// ɮקjp

fso = new ActiveXObject("Scripting.FileSystemObject");
folderPath = "c:\\windows\\system32";	// |vD
folderPath = "d:\\users\\jang\\matlab\\toolbox\\machineLearning";
folderObj = fso.GetFolder(folderPath);
WScript.Echo(folderPath + " ؿjpO " + folderObj.Size + " bytes.");

Wz{A嫬ܵGpUG

c:\windows\system32 ؿjpO 1116543626 bytes.

t@ӱ`ΡAhO޲z̭nˬdCӤHb d:/users UҦΪϺФjpAiϥΤUCdҨӹFG

lɡ]dirSize02.js^G]ǦϰUYi^
// Get directory sizes under d:/users

topDirName="d:/users";
fso = WScript.CreateObject("Scripting.FileSystemObject");
dirObj = fso.GetFolder(topDirName);

subFolderList=new Enumerator(dirObj.SubFolders);
for (subFolderList.moveFirst(); !subFolderList.atEnd(); subFolderList.moveNext()){
	dirName=subFolderList.item().name;
	dirSize=subFolderList.item().Size;
	WScript.Echo(dirName+" ===> "+dirSize+" bytes");
}

Wz{A嫬ܵGpUG

classifiedEmailBackup ===> 4737324602 bytes jang ===> 54129835620 bytes jang2 ===> 91708923441 bytes Windows Live Mail ===> 16105564241 bytes ]Ъ`NGѩWzdҥˬdC@ӤlؿҦΪŶAҥHɶ|[C^

ڭ̥iHϥ WSH ܥثeu@ؿAάOܥثeu@ؿApUG

lɡ]dir01.js^G]ǦϰUYi^
// ϥ WSH ܥثeu@ؿAΧܥثeu@ؿ

wshShell=new ActiveXObject("WScript.Shell");
WScript.Echo("ثeu@ؿG"+wshShell.CurrentDirectory);
wshShell.CurrentDirectory = "c:\\windows\\temp";
WScript.Echo("ܥثeu@ؿܡG"+wshShell.CurrentDirectory);

嫬ܵGpUG

ثeu@ؿGD:\users\jang\books\wsh\example ܥثeu@ؿܡGc:\windows\temp

UCoӽdҡACX c:\windows\temp ؿUҦɮסApUG

lɡ]fileList01.js^G]ǦϰUYi^
// CX@ӯSwؿUҦɮ

fso = new ActiveXObject("Scripting.FileSystemObject");
folderPath="c:\\windows\\temp";
fsoFolder = fso.GetFolder(folderPath);
fileList = new Enumerator(fsoFolder.Files);
WScript.Echo("Files under \""+folderPath+"\":");
for (fileList.moveFirst(); !fileList.atEnd(); fileList.moveNext())
	WScript.Echo(fileList.item());

ѩXAbئCAŪ̽ЦۦլݬݦdҡC

UCoӽdҡACXϺоΨʽG

lɡ]driveList01.js^G]ǦϰUYi^
// CXҦϺо

fso = new ActiveXObject("Scripting.FileSystemObject");
driveTypes=["", "", "w", "Ϻо", "", "Ϻ"];
drives = new Enumerator(fso.Drives);		// Create Enumerator on Drives.
for (; !drives.atEnd(); drives.moveNext()) {	// Enumerate drives collection.
	x = drives.item();
	WScript.Echo(x.DriveLetter+":")
	WScript.Echo("\tx.DriveType = " + x.DriveType + " (" + driveTypes[x.DriveType] + ")");
	WScript.Echo("\tx.ShareName = " + x.ShareName);
	WScript.Echo("\tx.IsReady = " + x.IsReady);
	if (x.IsReady){
		WScript.Echo("	x.VolumeName = " + x.VolumeName);
		WScript.Echo("	x.AvailableSpace = " + x.AvailableSpace + " Bytes");
	}
}

嫬ܵGpUG

C: x.DriveType = 2 (w) x.ShareName = x.IsReady = true x.VolumeName = x.AvailableSpace = 24901296128 Bytes D: x.DriveType = 2 (w) x.ShareName = x.IsReady = true x.VolumeName = sWϺа x.AvailableSpace = 17471188992 Bytes E: x.DriveType = 4 () x.ShareName = x.IsReady = true x.VolumeName = hp LaserJet 3800 x.AvailableSpace = 0 Bytes ...
JScript {]pPΡGΩ WSH