SoFunction
Updated on 2025-03-09

Js uses objects to execute .bat files and cmd commands

(Windows Script Host Runtime Library) is an object, and the corresponding file is C:/WINDOWS/system32/, which 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.

Installation object: regsvr32

Uninstall the object: regsvr32 -u or regsvr32 /u

For Example:

1. Create a file and store it in the root directory of D:, which is used to copy the *txt file to the d:/test directory.

Copy the codeThe code is as follows:

md test
copy d:/*.txt d:/test
pause

2. Create an object and run the file directly from the object.

Copy the codeThe code is as follows:

var objShell;
objShell=new ActiveXObject("");
var iReturnCode=("c:/",0,true);

3. Create an object and run the CMD command directly from the object.

Copy the codeThe code is as follows:

var objShell
var objShell= new ActiveXObject("")
var iReturnCode=(" /c md test",0,true)
iReturnCode=(" /c copy d:/*.text mytest",0,true)

The method is simple but very practical. Here is a recommendation for friends