Batch operation hiding batch processing itself Copy codeThe Code is 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 are normal batch processing commands and do not contain interactive commands such as pause set/p.
××××××××
Explanation:
This is to use the mta script language to create wscript in windows Using VBScript. shell: the batch processing that runs in the background using the run method provided in this control. The mst script language is equivalent to the html application. No matter what script language is used, you only need to create wscript provided by windows. in shell space, use the run method in the space to open it. We can also use JavaScript in the mta script language to do the same. @ echo off :: 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> the nul mta script language is basically the same as the html language, the mta script language is parsed using the mshta program, and the html is parsed using the browser (IE). It is recommended that you understand the html Script Language, this is not the script language in the format of vbs files. vbs script files are parsed using wscript. Remember to use mshta vbscript: createobject ("plug-in name") (window. close) Here window. close is the method in the mshta itself, that is, to close the program. Create the plug-in provided by windows in this format. You can see the method in the plug-in to understand what the script language does not understand. HI me
How can I hide the batch processing operation window?
This will 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
Rem started to write the batch code below
Summary:
Adding Any of the following statements to @ echo off can hide the execution result (the task to be hidden after the code tag)
The two codes have the same idea and different implementation methods:
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 & start
# Hide. vbs & exit)
This code will not pop up.
@ Echo off
If "% 1" = "h" goto begin
Mshta vbscript: createobject ("wscript. shell"). run ("% ~ Nx0 h ", 0) (window. close) & exit
: Begin
Rem started to write the batch code below
.....
Last one:
If not "% 1" = "h" mshta vbscript: createobject ("wscript. shell"). run ("% ~ Sf0 h % * ", 0) (window. close) & exit/B
Shift/1 is helpful 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 are normal batch processing commands and do not contain interactive commands such as pause set/p.
Pause
How to hide and Run batch files
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 that the parameter is null, and some applications require parameters. For example, in the cmd window, enter shutdowm-s-t 0, -s-t 0 is the parameter. Shutdown is % 0,-s is % 1,-t is % 2, and so on.
In the first line, we will skip this step. In the second line, we will use mshta to create a vbs program with the content createobject ("wscript. shell"). run (......). If the running batch name is a. bat, under C: \, % 0 indicates C: \ a. bat, % ~ Nx0 indicates a. bat. The h Parameter % indicates hidden running. Because you double-click to run, the First Batch Processing % 1 is empty, if is not true, and then run the next sentence. Then open yourself again and pass the parameter h. if yes, the system jumps to begin to start running.
These two lines are classic, and batch processing can be performed without a window.
Create a batch processing program to call the batch processing files to be executed,
My method is:Copy codeThe Code is as follows: @ echo off
Start/min 1.bat
Save the above Code as: 2.bat
Save your batch file as 1.bat. open 2.batbefore running, and then 1. bat will be minimized.