22-4 ?栫敤?戒护?楀???

WSH 磅︽琌㏑иゲ斗镑ъ㏑把计琵 WSH ㄣ紆┦

硂絛ㄒ㏑把计安砞и DOS ㏑跌怠块

cscript cmdArgument01.js Monday Tuesday Wednesday 眔挡狦 No. of arguments = 3 args(0)=Monday args(1)=Tuesday args(2)=Wednesday argumentList.js ﹍絏

﹍郎cmdArgument01.jsη︹跋办ㄢī
// ┮Τ块把计

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

// ┮Τ块把计
WScript.Echo("No. of arguments = " + WScript.Arguments.Count());
for (i=0; i<args.length; i++)
	WScript.Echo("args("+i+")="+args(i));

ㄤい args.Count() ㎝ args.length 常琌块把计计

硂絛ㄒ硋Ω冀郎絛ㄒ

﹍郎audioPlay02.jsη︹跋办ㄢī
// 冀郎

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);
}

璝璶代刚絛ㄒ DOS 跌怠块

cscript audioPlay02.js chimes.wav notify.wav ding.wav 碞钮硈尿冀羘

Hint
瓃郎常竒絛ㄒヘ魁ぇ璝璶碝т郎 c:\windows\media ヘ魁碝т


JScript 祘Α砞璸籔莱ノノ虫诀 WSH 吏挂