Fast setup and debugging of Windows Services (C # plots) using the Bat Batch installation service program

Source: Internet
Author: User
Tags visual studio 2010

First, what is Windows services?

A: Microsoft Windows services (that is, previous NT services) enable you to create executable applications that can run for a long time in their own Windows sessions. These services can be started automatically when the computer starts, can be paused and restarted, and does not display any user interface. This makes the service ideal for use on the server, or at any time, in order not to affect other users working on the same computer, which requires long-running functionality. You can also run a service in a different security context than a specific user account or a default computer account that is a logged-on user.

Second, create a Windows service.

Open: Visual Studio + + new + = project + Windows Services,

Click OK = = Generate the Service1.cs file view right-click + Add installer = build ProjectInstaller.cs View Page Setup ServiceInstaller1 in the startup mode, Windows Service Name,

Then in the Setup serviceProcessInstaller1 account information, select "Local System ",

At this point, the installer and the framework have been built, and then you can write your own business code in Service1.cs's OnStart code view,

At this point, the full Windows service has been created.

Installation Services:

@echo off
@echo off
Set Filename=lxserver.exe
Set Servicename=service1
Set frameworkdc=%systemroot%\microsoft.net\framework\v4.0.30319



echo the. NET Framework 4.0 is not installed on your machine and the installation is about to terminate.
Echo does not have the. NET Framework 4.0 installed on your machine and the installation is about to terminate >installservice.log


CD%frameworkdc%

echo you have the. NET Framework 4.0 installed on your machine and you can install the service >installservice.log
Echo.
Echo. >>installservice.log
C:\Windows\Microsoft.NET\Framework\v4. 0.30319\installutil.exe E:\Debug\SendSmsService.exenet start Sendsmsecho----------------------------- Echo Service installation successful echo-----------------------------pause

net start " service name "

Uninstall Service:

net start " service name "

@echo offnet Stop sendsmsc:\windows\microsoft.net\framework\v4. 0.30319\installutil.exe E:\Debug\SendSmsService.exe/uecho-----------------------------Echo         Service Uninstall succeeded Echo-----------------------------pause   

Third, debug Windows services.

Open the tools in the Visual Studio 2010 toolbar and attach to the process = + Click OK, select the name of the service to debug in the list and click Attach to Debug. In the program you can debug with just F9, note that the Windows service keeps the version consistent.




Transfer from others:

Http://www.cnblogs.com/Warmsunshine/p/4031367.html
Http://www.cnblogs.com/stone_w/archive/2012/06/26/2563483.html

Fast setup and debugging of Windows Services (C # plots) using the Bat Batch installation service program

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.