❶ 用Javascript調用cmd並執行命令
建立test.bat文件,存於D:根目錄下,作用是將*txt文件拷貝到d:/test目錄下。
md test
d:/*.txt d:/test
pause
創建WScript.Shell對象,由該對象直接運行test.dat文件。
var objShell
objShell=new ActiveXObject("WScript.Shell")
var iReturnCode=objShell.Run("c:/test.bat",0,true)
創建WScript.Shell對象,由該對象直接運行CMD命令。
var objShell
var objShell= new ActiveXObject("WScript.Shell")
var iReturnCode=objShell.Run("cmd.exe /c md test",0,true)
iReturnCode=objShell.Run("cmd.exe /c d:/*.text mytest",0,true)