Windows service is installed and uninstalled (by Sc.exe)

1. Install

 

  • Create a text file, rename ServiceInstall.bat , will replace ServiceInstall.bat content for:

Create SC "the Verity Device-Service Platform" binPath = "~% dp0WindowsService_HardwareDevice.exe"

SC Description "the Verity Platform-Service Device" "providing device is connected, the FMC voltage, the PLL clock, FPGA configuration, register access and other related services"

SC config "the Verity Platform Service Device "Start = AUTO

sc Start" Verity Platform Device Service "

PAUSE

 

Note 1: "Verity Platform Device Service" is the service name;

Note 2: WindowsService_HardwareDevice.exe own created for WCF services used to carry the Windows Installer service, created as follows:

     https://docs.microsoft.com/zh-cn/dotnet/framework/wcf/feature-details/how-to-host-a-wcf-service-in-a-managed-windows-service

  Note 3: The role of pause is finished running .bat do not quit, to view operating results (also available @ cmd.exe).

 

  • To run as administrator  ServiceInstall.bat complete Windows service is installed.

 

2. Uninstall

 

  • Create a text file, rename ServiceUninstall.bat , will replace ServiceUninstall.bat content for:

sc stop "Verity Platform Device Service"

sc delete "Verity Platform Device Service" binPath= "%~dp0WindowsService_HardwareDevice.exe"

@cmd.exe

 

To run as administrator  ServiceUninstall.bat complete Windows service is installed.

 

 

 

Guess you like

Origin www.cnblogs.com/dhqy/p/12082555.html