Use the wscript. Shell object to hide the implementation code of the CMD command line runtime box

Source: Internet
Author: User

1. wscript. shell (Windows Script Host Runtime Library) is an object corresponding to c: \ windows \ system32 \ wshom. OCX, wscript. shell is a component used by the server system. Shell is the meaning of "shell". This object can perform common operations on the operating system shell, such as running Program , Read and write the registry, environment variables, and so on. This object is usually used in VB or vbs programming.

2. Install wscript. Shell object: regsvr32 wshom. ocx
Uninstall wscript. Shell object: regsvr32-u wshom. ocx or regsvr32/u wshom. ocx
3. For example, assume that all the mytest *. ISO files are in the C: root directory. Create the mytest directory and copy the mytest *. ISO file to the mytest directory.

Create the testcopy. BAT file and store it in the C: root directory.CopyCodeThe Code is as follows: MD mytest
Copy c: \ mytest *. ISO mytest
Pause

Double-click testcopy. dat to view the newly created mytest directory and the copied mytest *. ISO file.

You can use either of the following methods to hide the CMD command line window.

(1) create a wscript. Shell object that runs the testcopy. dat file. The corresponding vbs file: testcopy1.vbs. Double-click testcopy1.vbs to see the effect.Copy codeThe Code is as follows: dim objshell
Set objshell = wscript. Createobject ("wscript. Shell ")
Ireturncode = objshell. Run ("C: \ testcopy. Bat", 0, true)

(2) create a wscript. Shell object, which directly runs the doscommand and the command in testcopy. dat. The corresponding vbs file is testcopy2.vbs.Copy codeThe Code is as follows: dim objshell
Set objshell = wscript. Createobject ("wscript. Shell ")
Ireturncode = objshell. Run ("cmd.exe/c md mytest", 0, true)
Ireturncode = objshell. Run ("cmd.exe/C copy c: \ mytest *. ISO mytest", 0, true)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.