Windows services cannot start with scripts

Source: Internet
Author: User
Tags goto

1. Create a Windows Service project

Project Name: Servicedemo

2. Add load start and unload service scripts

Load and start batch processing:

1 @echo off2 if exist"%systemroot%/microsoft.net/framework/v4.0.30319"GotoInstall3 EchoPlease install.NetFramework v4.0 first.4 Pause5 Goto End6 : Install7%systemroot%/microsoft.NET/framework/v4.0.30319/installutil "ServiceDemo.exe"8 Net Start"ServiceDemo.exe"9 PauseTen : End

To uninstall a batch process:

1 @echo off2 if exist"%systemroot%/microsoft.net/framework/v4.0.30319"GotoUninstall3 EchoPlease install.NetFramework v4.0 first.4 Pause5 Goto End6 : Uninstall7%systemroot%/microsoft.NET/framework/v4.0.30319/installutil/uninstall "ServiceDemo.exe"8 Pause9 : End

3. Here's the problem.

The service was loaded successfully but did not start successfully.

4. Analysis

From the first diagram you can see that the service is Service1, so change the load script to:

1 @echo off2 if exist"%systemroot%/microsoft.net/framework/v4.0.30319"GotoInstall3 EchoPlease install.NetFramework v4.0 first.4 Pause5 Goto End6 : Install7%systemroot%/microsoft.NET/framework/v4.0.30319/installutil "ServiceDemo.exe"8 Net StartService19 PauseTen : End

Successfully started:

Windows services cannot start with scripts

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.