Windows services, install, start, stop, configure, a batch file to fix

Source: Internet
Author: User

Relatively speaking, it is relatively common, if any man has a better way to achieve, or found that there are shortcomings, please advise.

@echo off

echo.--------------------------------------------------echo.----Technical support: CC--------echo.----Today is%date%.--------Echo.--------------------------------------------------echo. Detecting if the service is already created, please wait ... sc query Njfkreportanalyticalservice >nul && Goto:startserver | | goto:install:installset/p choice=windows The service is not installed, do you want to install it? Y (yes)/n (NO) Please select: if/i "%choice%" = = "Y" (SC create njfkreportanalyticalservice binpath= "%~dp0njfkreportanalytical.exe"Echo. ------------Service creation is complete. ------------Goto:StartServer:StartServerecho. Detecting service running status, please later ... net start|findstr/i/C: "Njfkreportanalyticalservice" >null && goto:stopserverset/p Choice=windows Open the Njfkreportanalyticalservice (Nanjing Message Resolution Service) service? Please select Y (yes)/n (NO): if/i "%choice%" = = "Y" (Echo. Service startup ...net start NjfkreportanalyticalserviceEcho. ------------Service is started------------Goto:configserver) if/i "%choice%" = = "n" Goto:noecho. Invalid input please reenter. Goto:funish:StopServerecho. Service running .... set/p choice=windows stop Njfkreportanalyticalservice (Nanjing Message parsing service)? Please select Y (yes)/n (NO): if/i "%choice%" = = "Y" (Echo. Service stopped ...net stop NjfkreportanalyticalserviceEcho. ------------Service is stopped------------Goto:funish) if/i "%choice%" = = "n" Goto:noecho. Input is not valid please re-enter.: configserverset/p Choice=windows is powered on with system Autorun? Please select Y (yes)/n (NO): if/i "%choice%" = = "Y" (echo. Service auto-open configuration ...sc config Njfkreportanalyticalservice start= AUTOecho.------------Auto-open configuration complete------------Goto:funish) if/i "%choice%" = = "n" Goto:no:funishecho. Operation completed &&goto:no:no Pause

There are a few small points to note, that is
1, determine if the service has been created

2. Determine the Windows service health status

3, about how to get the file path.

Windows services, install, start, stop, configure, a batch file to fix

Related Article

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.