In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how batch processing hides its own window. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
The code is as follows:
@ echo oFF
:: code by LZ-MyST QQ:8450919 BLOG: http://hi.baidu.com/lzmyst http://www.clxp.net.cn
If "1" neq "1" (
> "% temp%\ tmp.vbs" echo set WshShell = WScript.CreateObject^ (^ "WScript.Shell^" ^)
> "% temp%\ tmp.vbs" echo WshShell.Run chr ^ (34 ^) ^ & 0 ^ & chr ^ (34 ^) ^ & ^ "1 ^", 0
Start / d "% temp%" tmp.vbs
Exit
)
:: from here on, it's your batch code. The DOS black box flashes past and goes to the background to run.
Pause
You will see the CMD process with a hidden window in the task manager
The method of hiding cmd window when running bat
The way to hide the cmd window when running bat can edit a vbs script in which to run the batch program with a hidden window.
The code is as follows:
Set ws = CreateObject ("Wscript.Shell")
Ws.run "cmd / c batch Program name", vbhide
Copy the above code into 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 and run the specified batch program.
This vbs script can also be called directly in the bat environment to hide the bat itself.
Sum up by yourself, do a few examples, and try it out if you are interested!
The code is 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
Here are a few experts to sort it out.
Several ways to hide the batch run window.
(1) it is realized by batch command. Cons: you will see a window flash away. Advantages: simple, can be added directly.
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
Pause
(2) use vbs script to realize hiding. Cons: call trouble points. Advantages: almost no trace (non-absolute, refers to the average user)
HideRun.vbs
The code is as follows:
CreateObject ("WScript.Shell"). Run "cmd / c D:/test.bat", 0
Where D:/test.bat is your batch path
. .
Another idea is to convert bat to vbs, then vbs generates a temporary bat file, and then WScript.Shell.Run hides and starts the temporary bat.
HideRun.bat
The code is as follows:
Echo CreateObject ("WScript.Shell") .Run "cmd / c D:/test.bat", 0 > $tmp.vbs
Cscript.exe / e:vbscript $tmp.vbs
Del $tmp.vbs
This batch does not actually hide the batch itself, but most of the following hides the principle and basis of invoking the batch.
HideRun.js
The code is as follows:
New ActiveXObject ('WScript.Shell'). Run (' cmd / c Dappled peg Test.battalion page0)
What are the benefits of using Javascript? String variables in js can be in single quotation marks, which makes it easy to call the command line as an argument, and js well supports the use of multiple lines of statements; delimited into one line. It is important to note that js should be case-sensitive, the method
You must use parentheses and end with a semicolon. So it becomes the following command:
The code is as follows:
Mshta "_ javascript:new ActiveXObject ('WScript.Shell'). Run (' cmd / c DRV _ hand test.battalion pr. 0); window.close ()"
Usually, the system administrator will push some scripts to the client and run them, or copy the batch files to the client and run them by the user himself. But most scripts will pop up a DOS window with a black background when they run, which will confuse many users.
Do something, or even close the running window by mistake. Fortunately, the DOS window of a batch file can be hidden. Here are several ways to hide the batch run window.
1. Basics
HideRun.vbs
CreateObject ("WScript.Shell"). Run "cmd / c D:/test.bat", 0
Where D:/test.bat is your batch path
Another idea is to convert bat to vbs, then vbs generates a temporary bat file, and then WScript.Shell.Run hides and starts the temporary bat.
HideRun.bat
The code is as follows:
Echo CreateObject ("WScript.Shell") .Run "cmd / c D:/test.bat", 0 > $tmp.vbs
Cscript.exe / e:vbscript $tmp.vbs
Del $tmp.vbs
This batch does not actually hide the batch itself, but most of the following hides the principle and basis of invoking the batch.
HideRun.js
New ActiveXObject ('WScript.Shell'). Run (' cmd / c Dappled peg Test.battalion page0)
What are the benefits of using Javascript? String variables in js can be in single quotation marks, which makes it easy to call the command line as an argument, and js well supports the use of multiple lines of statements; delimited into one line. It is important to note that js should be case-sensitive, the method
You must use parentheses and end with a semicolon. So it becomes the following command:
Mshta "_ javascript:new ActiveXObject ('WScript.Shell'). Run (' cmd / c DRV _ hand test.battalion pr. 0); window.close ()"
two。 Use shortcuts
If you want to hide a batch itself, you can refer to a shortcut in the attachment and modify the relevant path in the attachment to hide and start your batch. You can use vbs to create a .lnk, but you can also use batch processing (echo one first
Vbs comes out)
3. Take advantage of system servic
You can set up a system service and then start the service to start batch processing. The disadvantage is that it is slow to start the service and requires administrator privileges.
Runassrv add / cmdline: "C:/Windows/System32/cmd.exe / c D:/test.bat" / name: "mysrv"
Net start mysrv
4. Using at to schedule tasks
With at, you can create a scheduled task that can be run in the background without entering the / interactive parameter. But Jian must have administrator privileges to use at.
At 09:10 "cmd / c D:/Test.bat"
Then at 9:10 the system will automatically run the bat with SYSTEM privileges in the background.
5. Using ftype file association
Ftype batfile=C:/Windows/System32/mshta "_ javascript:new ActiveXObject ('WScript.Shell'). Run (' cmd / c% 1); window.close ();"
6. Other users
Windows 2k/XP supports multiple users. If you can log in to the desktop of another account in the background and run a batch process, you can completely achieve the purpose of hiding.
7. Compile to an executable file
Many methods can be implemented, and the workers that can be directly utilized have Quick Batch file compiler.
This is the end of this article on "how to hide your own window". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.