22-3 ?叫???用程?

YnLε{AiHͤ@ WSH shell AMAϥ run() ƨөIsLε{C

ҦpAYn@nɮסAڭ̥iHIsbIAdҦpUG

lɡ]audioPlay01.js^G]ǦϰUYi^
// 񭵰Tɮ
audioFile = "chimes.wav";
shell = new ActiveXObject("Wscript.Shell");
command = "sndrec32 /play /close \"" + audioFile + "\"";
command = "soundRecorder /play /close \"" + audioFile + "\"";
command = "start " + audioFile;
WScript.echo(command);
shell.Run(command, 0);

WzdҡANiHť windows ҰʪġC]аOonz}A~ť쭵ġC^bWzdҤAshell.Run(command, 0) ĤGӰѼ 0AN}ҩҩIsε{CpGAѼơ]αNѼƳ]w 1^ANiHݨC

Hint
ڭ̷M]iHIsC鼽񾹨ӼAOoOuΤMvA]C鼽񾹤ӪΤӺCFIϥοӼnɮסAwgְnFC

Hint
WzdҥuAΩ Windows XPCpG@~tάO VistaAAN sndrec32.exe 令 SoundRecorder.exeC

ڭ̤]iHϥ覡Ӷ}ҤpeaA shell.Run ĤGӰѼƴN]w 1A_hA|ݤpeaeAdҦpUG

lɡ]imageDisplay01.js^G]ǦϰUYi^
// ϥΤpeaܼvɮ
imageFile = "annie.jpg";
shell = new ActiveXObject("Wscript.Shell");
command = "mspaint " + imageFile;
shell.Run(command, 1); 

}ҫ᪺epUG

UCoӽdҡA|} DOS RO]æCX dir G^Hζ}ҰOƥ]øJ run01.js^A{XpUG

lɡ]run01.js^G]ǦϰUYi^
// p WSH Lε{

shell = WScript.CreateObject("WScript.Shell");	//  WSH Shell
shell.Run("cmd /K dir");			// } DOS ROð dir
shell.Run("wordpad.exe run01.js");		// }ҰOƥøJɮ

bWzdҤAҶ}Ҫε{|O}ҪAA WSH |᪺{XCYnε{QA~~᪺ WSH {XAiHb run() A[WĤTӰѼơAиոճoӽdҡG

lɡ]run02.js^G]ǦϰUYi^
// p WSH Lε{Aõε{~~ WSH {X

shell = new ActiveXObject("WScript.Shell");
intReturn = shell.Run("notepad " + WScript.ScriptFullName, 1, true);
shell.Popup("OƥwgQI");

bWzdҮɡAWSH |}ҰOƥAðdbOƥAOƥQA~|ĵiC

Hint
H JScript g WSH ɡAUC{XiH shell G
  1. shell = WScript.CreateObject("WScript.Shell");
  2. shell = new ActiveXObject("WScript.Shell");

ڭ̤]iHϥ Exec() ƨӰt@ε{AUӽdҥ}pLAܬTG

lɡ]exec01.js^G]ǦϰUYi^
//  WSH Isp

WshShell = new ActiveXObject("WScript.Shell");
oExec = WshShell.Exec("calc.exe");
// Y}ҡA򵥫ݡAܶ}ҧ
while (oExec.Status == 0)
	WScript.Sleep(100);
// LXT
WScript.Echo("Status = " + oExec.Status);
WScript.Echo("ProcessID = " + oExec.ProcessID);
WScript.Echo("ExitCode = " + oExec.ExitCode);


JScript {]pPΡGΩ WSH