JS 文件复制

<script>
var fso = new ActiveXObject("Scripting.FileSystemObject");
function readFile(filename) {       
 //var fso = new ActiveXObject("Scripting.FileSystemObject");
        var f = fso.OpenTextFile(filename, 1);
        var s = "";
        while (!f.AtEndOfStream)
            s += f.ReadLine() + "\n";
        f.Close();
        alert(s);


}

 function writeFile(filename, filecontent) {    
 var f, s;
       // fso = new ActiveXObject("Scripting.FileSystemObject");
     fso.CreateTextFile("", true);
        f = fso.OpenTextFile(filename, 2, true);
        f.WriteLine(filecontent);
        f.Close();
 }

 

</script>
</head>

<body>
<input type="button" id="testID" onclick="readFile('C:\\Users\\lkf73943\\Desktop\\TestHtml\\test.txt')" style="width:50px; height:50px;"/>
<br />
<br />
<input type="button" id="testID_1" onclick="writeFile('C:\\Users\\lkf73943\\Desktop\\TestHtml\\test.txt','lets go!!')" style="width:50px; height:50px;"/>

</body>
</html>

 

var shell = new ActiveXObject("Wscript.Shell");
    shell.run("cmd.exe /k "+"d: & cd test & copy cmd.txt+,, & exit");
    shell=null;

posted on 2012-12-22 16:30  木叶堂  阅读(392)  评论(0编辑  收藏  举报

导航