method to hide the cmd window when running Bat (Bat hidden window hides run bat file) _vbs

Source: Internet
Author: User
The cloud-dwelling community here is simple to organize the common method, convenient for everyone to use. It's all through VBScript code.
The way to hide the cmd window while running a bat can edit a VBS script in which the batch program runs with a hidden window.
Copy Code code as follows:

Set ws = CreateObject ("Wscript.Shell")
Ws.run "cmd/c Batch program name", Vbhide

Copy the code above to Notepad, save it as "Runbat.vbs" or another name (the extension must be. vbs), and then click Run the generated script Runbat.vbs to hide the run of the specified batch program.
This VBS script can also be invoked directly in the bat environment to hide the bat itself.
Summary of their own, do a few examples, interested to go to the test Ah!
Copy Code code as follows:

Set ws = CreateObject ("Wscript.Shell")
Wscript.Sleep 1200 Ws.run "cmd/c start Winrar.exe", vbhide
Wscript.Sleep 2200 Ws.run "cmd/c start Msimn.exe", vbhide
Wscript.Sleep 1200 Ws.run "cmd/c start Iexplore.exe", vbhide

Hide Run Hide_run.vbs
In fact, nothing original, but the feeling is also practical, encapsulated, can be used as a command tool. But with caution ~
Hide_run.vbs [Command1] ...
Copy Code code as follows:

On Error Resume Next
Set objargs=wscript.arguments
For I=0 to Objargs.count-1
Strargs=objargs (I)
If strargs<> "" Then Hiderun (Strargs)
Next
function Hiderun (h)
Set Owsl=wscript.createobject ("Wscript.Shell")
Rtn=owsl.run (H,0,false)
End Function

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.