Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

A tutorial on how to minimize batch programs when they start

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains the "method tutorial to minimize batch program startup". The explanation in this article is simple, clear and easy to learn and understand. let's study and learn the method tutorial to minimize batch program startup.

Batch hide run hide batch itself

The 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 commands and cannot contain interactive commands such as pause set/p

× × ×

Explanation:

This is to use the scripting language of mta to create the wscript.shell control in windows using VBScript, and use the run method provided in this control to run the batch processing in the background. Mst scripting language is equivalent to html application, no matter what scripting language is used, as long as you can create the wscript.shell space provided by the windows system. Using the run method in this space to open it, we can also use JavaScript in the mta scripting language to do the same @ echo off:: batch hidden run if "% 1" = = "h" goto begin mshta "_ javascript:new ActiveXObject ('wscript.shell'). Run ('% ~ nx0 hints 0) Window.close () "& & exit:: the code to run: begin echo OK pause > nul mta scripting language is basically the same as html language. Mta scripting language is parsed by mshta program, and html is parsed by browser (IE). It is suggested to take a look at html scripting language. This is not the scripting language in vbs file format. The vbs script file is parsed with wscript. Just remember to use mshta _ vbscript:createobject ("plug-in name") (window.close) where window.close is the method in the mshta itself, which is to close the program. It is OK to create the plug-in provided by windows in this format. The method in the plug-in can read the documentation and understand that you can HI me if you don't understand the scripting language.

How to hide the run window of batch processing

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 to write the batch code under rem.

Summary:

Adding any of the following sentences under @ echo off can have the effect of hiding execution. (after the code tag, you want to hide the task you perform.)

The idea of the two sentences of code is the same, but the means of implementation are different. Please savor it carefully:

If "% 1" = = "h" (goto code) else (mshta _ vbscript: create object ^ ("wscript.shell" ^). Run^ ("% ~ fs0 h", 0 ^) ^ (window.close^) & exit)

If exist # hide.vbs (del # hide.vbs& goto code) else (echo create object ^ ("wscript.shell" ^). Run "% ~ fs0", 0 > # hide.vbs&start

# hide.vbs&exit)

This code will not flash a prompt.

@ echo off

If "% 1" = = "h" goto begin

Mshta _ vbscript:createobject ("wscript.shell"). Run ("% ~ nx0 h", 0) (window.close) & & exit

: begin

Start to write the batch code under rem.

.

The 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 commands and cannot contain interactive commands such as pause set/p

Pause

How to make batch files run hidden

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 an empty parameter, while some applications require parameters, such as entering shutdowm-s-t 0 in the cmd window, where-s-t 0 is the parameter. Shutdown is 0MagneMays, 1mai Muth is 2, and so on.

Let's skip the first line and look at the second line, which means to create a vbs program using mshta. The content is: createobject ("wscript.shell"). Run (…) . If the batch you are running is named a.bat, under C:\, then% 0 represents C:\ a. Batthol% roomnx0 represents a.bat. H pole parameter% 1. 0 indicates hidden operation. Because you double-click to run, the first batch% 1 is empty and if is not valid, so run the next sentence instead. Then open yourself again and pass the parameter h, where if is set up and jump to begin to start running.

These two lines are classic and can make the batch run windowless.

Make another batch program to call the batch file that is about to be executed

My method is:

The code is as follows:

@ echo off

Start / min 1.bat

Save the above code as: 2.bat

Then save your batch file as 1.bat, open 2.bat before running, and 1.bat will run to a minimum.

Thank you for your reading, the above is the content of "how to minimize when batch programs start". After the study of this article, I believe you have a deeper understanding of the problem of minimizing the method tutorial when batch programs start, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report