解答:此题 http://www.iteye.com/problems/48046
转自:http://www.blueshop.com.tw/board/show.asp?subcde=BRD20061014093911FUN&fumcde=FUM20041006152641OLG
试测过可用.
wsh=new ActiveXObject("WScript.Shell"); fso=new ActiveXObject("Scripting.FileSystemObject"); label1: for(;;) { tmp=Math.random()+".tmp"; //下面这句这也太难以想像了...用来代替sleep. try{fso.CreateTextFile(tmp,false,true);break;}catch(e){continue label1;} } wsh.Run('cmd /c dir/w > '+tmp,0,1); r=fso.OpenTextFile(tmp,1); alert(tmp+'\n\n'+r.ReadAll()); r.Close(); fso.DeleteFile(tmp);