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 means "shell". This object can perform commonly used operations in the operating system shell, such as running programs, reading and writing registry, environment variables, etc. This object is usually used in VB or VBS programming.
Install WScript.Shell object: regsvr32 WShom.Ocx
Uninstall WScript.Shell object: regsvr32 -u WShom.Ocx or regsvr32 /u WShom.Ocx
For Example:
1. Create a test.bat file and store it in the root directory of D:, which is used to copy the *txt file to the d:/test directory.
The code copy is as follows:
md test
copy d:/*.txt d:/test
pause
2. Create a WScript.Shell object, and run the test.dat file directly from the object.
The code copy is as follows:
var objShell;
objShell=new ActiveXObject("WScript.Shell");
var iReturnCode=objShell.Run("c:/test.bat",0,true);
3. Create a WScript.Shell object, and run the CMD command directly from the object.
The code copy 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 simple but very practical. Here is a recommendation for friends