Home > Article > Web Front-end > Js uses WScript.Shell object to execute .bat files and cmd commands_javascript skills
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 used by the server system. Shell means "shell". This object can perform common operations of the operating system shell, such as running programs, reading and writing the 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 the test.bat file and save it in the D: root directory. The function is to copy the *txt file to the d:/test directory.
2. Create a WScript.Shell object and run the test.dat file directly from this object.
3. Create a WScript.Shell object and run the CMD command directly from this object.
The method is very simple but very practical. I recommend it to my friends