How to minimize _dos/bat when a batch process is started

Source: Internet
Author: User
Batch hide run hidden batch itself
Copy Code code as follows:

@echo off
If "%1" = = "h" goto begin
Start Mshta vbscript:createobject ("Wscript.Shell"). Run ("" "%~nx0" "H", 0) (window.close) &&exit
: Begin
:: The following is a normal batch order, do not contain pause set/p and other interactive commands
xxxxxxxx

Explain:
This is using VBScript in the scripting language of the MTA to create Windows Wscript.Shell this control, the batch that runs in the background of the Run method provided in this control, the MST scripting language is the equivalent of an HTML application, no matter what scripting language, only To be able to create a Windows system-provided Wscript.Shell this space, open with the Run method in this space we can also use JavaScript in the MTA scripting language to do the same @echo off:: Batch hide Run if "%1" = = "h" goto Begin Mshta "javascript:new activexobject (' Wscript.Shell '). Run ('%~nx0 h ', 0); Window.close ();" &&exit:: Code to run: Begin echo OK Pause>nul MTA scripting language is essentially the same as HTML language, the MTA scripting language is parsed using a Mshta program, and HTML is parsed by the browser (IE) It is recommended that you look at the HTML scripting language to see that this is not the script language in the format VBS file, the VBS script file is parsed with WScript as long as you remember to use Mshta vbscript:createobject ("Plug-in name") (Window.close) Here Window.close is the method within the Mshta itself, that is, to close the program. This format creates the Plug-ins that Windows provides, and the methods inside the plugin look at the document to see where the scripting language doesn't understand. HI, I

How can I hide a batch run window

This does not generate temporary files (compatible with space paths):

@echo off
If "%1" = = "h" goto begin
Mshta vbscript:createobject ("Wscript.Shell"). Run ("%~fs0 h", 0) (window.close) &&exit
: Begin
Start writing the code at the bottom of REM.


Summarize:
Add any of the following words below @echo off to hide the execution, (after the code tag is the task to hide the execution)
Two lines of code, the same idea, different means of implementation. Please savor:

If "%1" = = "h" (Goto Code) Else (Mshta vbscript:createobject^ ("Wscript.Shell" ^). run^ ("%~fs0 h", 0^) ^ (window.close^) & Exit

If exist #hide. vbs (DEL #hide. VBS &GOTO CODE) Else (Echo createobject^ ("Wscript.Shell" ^). Run "%~fs0", 0 > #hide. vbs& Amp;start

#hide. Vbs&exit)

This code does not flash from the prompt.
@echo off
If "%1" = = "h" goto begin
Mshta vbscript:createobject ("Wscript.Shell"). Run ("%~nx0 h", 0) (window.close) &&exit
: Begin
Start writing the code at the bottom of REM.
.....


Last one:
If not "%1" = = "h" Mshta vbscript:createobject ("Wscript.Shell"). Run ("%~sf0 h%*", 0) (window.close) &exit/b
SHIFT/1 's been a help to me.




@echo off
If "%1" = = "h" goto begin
Start Mshta vbscript:createobject ("Wscript.Shell"). Run ("" "%~nx0" "H", 0) (window.close) &&exit
: Begin
:: The following is a normal batch order, do not contain pause set/p and other interactive commands
Pause



How to keep batch files hidden from running
If "%1" = = "h" goto begin
Mshta vbscript:createobject ("Wscript.Shell"). Run ("%~nx0 h", 0) (window.close) &&exit
: Begin
If you double-click a batch, it is equivalent to null parameters, and some applications require parameters, such as Shutdowm-s-T 0 in the cmd window, where-S-T 0 is the parameter. Shutdown is%0,-s to%1,-t to%2, and so on.
The first line we skip and look at the second line, which means to create a VBS program using MSHTA, which reads: CreateObject ("Wscript.Shell"). Run (...). If the batch being run is named A.bat, under C:\, that% 0 represents c:\a.bat,%~nx0 a.bat. H Extremely parameter%1,0 represents a hidden run. Because you double-click to run, the first batch%1 is empty, if not set, and then run the next sentence. Then open yourself again and pass the parameter H, at which point if it is set, jump to begin to run.
These two lines are classic, allowing the batch to run without Windows.


Also make a batch program to invoke the batch file that will be executed.
My approach is to:
Copy Code code as follows:

@echo off
Start/min 1.bat

Save the above code as: 2.bat

Then save your batch file as 1.bat, and then turn on 2.bat before you run, then 1.bat to minimize the operation.

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.