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.
- 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.
- 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.
- Dim objshell
- Set objshell = wscript. Createobject ("wscript. Shell ")
- Ireturncode = objshell. Run ("cmd.exe/CMD mytest ", 0, true)
- Ireturncode = objshell. Run ("cmd.exe/CCopy C:/mytest *. ISO mytest ", 0, true)