JavaScript uses the Wscript.Shell object to execute the. bat file and the cmd command
Http://www.cnblogs.com/ZHF/p/3328439.html
Wscript.Shell (Windows Script Host Runtime Library) is an object and the corresponding file is c:/windows/system32/ Wshom.ocx,wscript.shell is a component that the server system will use. Shell is the meaning of "shell", this object can do the operating system shell commonly used operations, such as running programs, read and write registry, environment variables and so on. This object is usually used in VB or VBS programming.
Install Wscript.Shell object: regsvr32 wshom.ocx
Unload Wscript.Shell object: Regsvr32-u wshom.ocx or regsvr32/u wshom.ocx
For Example:
1. Create the Test.bat file, stored in the D: root directory, the role is to copy the *txt file to the D:/test directory.
MD Test copy d:/*.txt d:/test pause
2. Create a Wscript.Shell object that runs the Test.dat file directly from the object.
var Objshell; Objshell=new ActiveXObject ("Wscript.Shell"); var ireturncode=objshell.run ("C:/test.bat", 0,true);
3. Create the Wscript.Shell object, run the cmd command directly from the object.
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 copy d:/*.text mytest ", 0,true)
JavaScript uses the Wscript.Shell object to execute the. bat file and the cmd command