JS using the Wscript.Shell object to execute the. bat file and the cmd command
Http://www.jb51.net/article/58669.htm
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.
Copy CodeThe code is as follows: MD test copy d:/*.txt d:/test pause
2. Create a Wscript.Shell object that runs the Test.dat file directly from the object.
Copy CodeThe code is as follows: 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.
Copy CodeThe code is as follows: 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)
The method is very simple, but very practical, this is recommended for small partners
JS using the Wscript.Shell object to execute the. bat file and the cmd command