Hide cmd command line running using wscript. Shell object

Source: Internet
Author: User

This blog (Http://blog.csdn.net/livelylittlefish) Post the notes prepared by the author (, Xiaoyu) on the relevant research and study content. You are welcome to correct them!

 

Hide cmd command line running using wscript. Shell object

 

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 programs, reading and writing registries, and environment variables. 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.

  1. MD mytest
  2. Copy C:/mytest *. ISO mytest
  3. 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.

  1. Dim objshell
  2. Set objshell = wscript. Createobject ("wscript. Shell ")
  3. 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.

  1. Dim objshell
  2. Set objshell = wscript. Createobject ("wscript. Shell ")
  3. Ireturncode = objshell. Run ("cmd.exe/CMD mytest ", 0, true)
  4. Ireturncode = objshell. Run ("cmd.exe/CCopy 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.