Jscript 和本地进程通信

 

< HTML >
< HEAD >
< TITLE ></ TITLE >
</ HEAD >
< BODY >
< INPUT type = " button "  value = " Button "  ID = Button1 onclick = " main() " >
< pre id = CONSOLE style = " COLOR:white;BACKGROUND-COLOR:black " ></ pre >
< script language = javascript >
<!--
// -------------------------------------------------------------------------
var  WS  =   new  ActiveXObject( " WScript.Shell " );
// -------------------------------------------------------------------------
function  println(str)
{
    CONSOLE.insertAdjacentText(
"beforeEnd", str + " ");
}

// -----------------------------------------------------------------------------
function  get_exec_list(command)
{
    
var list = new Array();
    
var pros = WS.Exec(command);
    
while(!pros.StdOut.AtEndOfStream)
    
{
        list.push(pros.StdOut.ReadLine());
    }

    
return(list);
}

// -------------------------------------------------------------------------
function  main()
{
    
var list = get_exec_list("cmd.exe /c cd / && dir");
    
for(var c = 0; c < list.length; c++)
    
{
        println(list[c]);
    }

}

// -->
</ script >
</ BODY >
</ HTML >

你可能感兴趣的:(JavaScript,html,list,function,command,button)