22-4 ��������������������?

WSH OHROCDA]ڭ̥ROCѼơA~ WSH uʡC

HUoӽdҡAiH@@LXROCѼơA]ڭ̦b DOS ROJG

cscript cmdArgument01.js Monday Tuesday Wednesday ioUCGG No. of arguments = 3 args(0)=Monday args(1)=Tuesday args(2)=Wednesday argumentList.js lXpUG

lɡ]cmdArgument01.js^G]ǦϰUYi^
// CXҦJѼ

args=WScript.Arguments;
if (args.Count()==0) {
	WScript.Echo("Usage: " + WScript.ScriptName + " x y z ...");
	WScript.Quit();
}

// CXҦJѼ
WScript.Echo("No. of arguments = " + WScript.Arguments.Count());
for (i=0; i<args.length; i++)
	WScript.Echo("args("+i+")="+args(i));

䤤 args.Count() M args.length ONJѼƪӼơC

UoӽdҥiHv񭵮ɮסAdҦpUG

lɡ]audioPlay02.js^G]ǦϰUYi^
// hӭɮ

args=WScript.Arguments;
if (args.Count()==0) {
	WScript.Echo("Usage: " + WScript.ScriptName + " file1.wav file2.wav file3.wav ...");
	WScript.Quit();
}

shell = new ActiveXObject("Wscript.Shell");
for (i=0; i<args.length; i++){
	command = "sndrec32 /play /close " + args(i);
	shell.Run(command, 0, true);
}

YnզdҡAiHb DOS JpUG

cscript audioPlay02.js chimes.wav notify.wav ding.wav NiHťTӭijs򼽩nC

Hint
WzTӭɮסAwgbdҥؿUCYnMhɮסAiH c:\windows\media ؿMC


JScript {]pPΡGΩ WSH