Transferred from: Http://itindex.net/detail/38012-bat-%E6%B5%8F%E8%A7%88%E5%99%A8-%E7%A8%8B%E5%BA%8F
Running the specified program is easy when the computer starts up or when it is set to time. But sometimes it needs to run without displaying the main interface and hiding it in the background. For example: A piece of bat batch processing to delete the default share when booting; Boot auto Run browser hidden to descendants open the specified webpage, etc., I hope all the actions are not visible to the user. If you also have this requirement, here I have collected a few ways to let the batch, browser and other programs hidden into the running method may be able to help you.
- Method One: Hiderun.vbs script file
Code: CreateObject ("Wscript.Shell"). Run "cmd/c D:test.bat", 0
Copy the above code into a text file and save it as a. vbs file (such as Hiderun.vbs), where D:test.bat is the batch file you want to run.
- Method Two: Hiderun.bat batch processing file
Code:
Echo CreateObject ("Wscript.Shell"). Run "cmd/c d:test.bat",0> $tmp. Vbscscript.exe/e:vbscript $tmp. Vbsdel $tmp. vbs
Or:
Mshta vbscript:createobject ("Wscript.Shell"). Run ("IExplore http://luckerme.com", 0) (Window.close)
Select one of the above codes to copy to a text file, and modify the custom content to save as a. bat file (such as Hiderun.bat).
- Method Three: Hiderun.js file
Code:
New ActiveXObject (' Wscript.Shell '). Run (' cmd/c d:test.bat ', 0);
Copy the above code into a text file and save it as a. js file (e.g. Hiderun.js). JavaScript string variables can be used in single quotation marks, so that the command line as a parameter call, and JS very good support for multi-line statements; The separation is written as a line. Note that: JS to be case-sensitive, the method must be in parentheses, the end must have a semicolon. So the command line is written as:
Mshta "javascript:new activexobject (' Wscript.Shell '). Run (' cmd/c d:test.bat ', 0); Window.close () "
- Method four: Using System services
Code:
Runassrv add/cmdline: "c:windowssystem32cmd.exe/c d:test.bat"/name: "Myservicesname" net start Myservicesname
You can set up a system service with SC and then start the service to start the batch process. The disadvantage is that the startup service is slow and requires administrator privileges.
- Method Five: Use at to schedule tasks
Code:
At "cmd/c D:test.bat"
Use at to create a scheduled task that can be run in the background without entering the/interactive parameter. You must have administrator privileges to use at. The bat is then automatically run in the background with system privileges.
- Method Six: Use third-party software
Today's search found a small green software named Hou Task Scheduler (OnTimer.exe) to perform scheduled/recurring tasks. Although the software is small, the function is very big. It can be used to execute program, DOS command, download program from HTTP server, end process, simulate button, send email, wake on LAN, message prompt, shutdown, restart, logout, lock, Standby and so on. In which normal operation, parameter operation, execution dos "remarks" Start with "-H" is hidden execution, can meet our needs. Believe the introduction and download can go to the official page of the software: http://www.yryz.net/soft-OnTimer.htm
The top five methods are simple and convenient, all of which are system functions without the need for additional software. However, the Bat,vbs file that you create may be mistakenly deleted by the anti-virus software, and it is best to manually add the trust list to the antivirus software after setting it up. I am currently using the last method, with the help of OnTimer.exe, this small software, configuration is convenient. Also, after you join the startup item, 360 checks the boot item without prompting for a ban, and non-security items are not detected in the System check repair interface. Other kill soft not tested. You can both test and use the appropriate method to implement the function of hiding the running program.
6 ways to hide programs that run bat, browser, etc.