Windows Server registers the bat batch as a service that runs in the background and logs off correctly

Source: Internet
Author: User

Batch processing has the following characteristics:

1. When you log in to the current window to run, if you close the console, it will be closed together with the program you started.

2, if it is started in the form of start/b, then also in the console to close the latter log off the current window will also be closed together.

3. If started as VBS, logout of the current user will also be closed together.

There are several ways to resolve this:

1, using "Task Scheduler" to start batch processing, there are many trigger points, you can choose "Computer startup" trigger can also achieve the effect of boot, rather than log on to the desktop.

2, there is an error to start the Windows service mode, the "SC" command to register the service, and then in the form of Cmd.exe to boot (c:\windows\system32\cmd.exe/c C:\Python34\Scripts\ Shadowsocks\shadowsocks\run.bat), but this form is ostensibly a start-up unsuccessful service, but essentially the process already has python.exe the process exists, so it is successfully started, and this form is not able to stop or restart the service.

3, use "Bat_to_exe_converter" this software to convert Bat to EXE program, and then use "SC" or "Srvinstw.exe" to register this exe into the service, if the Python program will also face the 2nd step problem, But if you start something else, it is likely to succeed; there is a problem, this conversion program in the implementation of the converted EXE will be in the temporary folder under a "B2e.exe" process, I guess this is the basis for the execution of bat, but the details of what is not known, if you want to use, please be careful!

: http://www.jb51.net/article/20270.htm

4, the ultimate solution, the use of NSSM program

SSM Install <servicename>

Then in the list of services to start, this program for the bat registered as a service is very good, than the above three ways of the reliable.

Reference:

Http://stackoverflow.com/questions/415409/run-batch-file-as-a-windows-service

Windows Server registers the bat batch as a service that runs in the background and logs off correctly

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.