WindowsService Class | MSBuild Extension Pack Help 4.0.12.0 |
CheckExists (Required: ServiceName Optional: MachineName, RemoteUser, RemoteUserPassword Output: Exists)
Delete (Required: ServiceName Optional: MachineName)
Disable (Required: ServiceName Optional: MachineName)
Install (Required: ServiceName, ServicePath, UserOptional: Force, StartupType, CommandLineArguments, Description, ServiceDependencies, ServiceDisplayName, MachineName, RemoteUser, RemoteUserPassword)
Restart (Required: ServiceName Optional: MachineName). Any running directly dependent services will be restarted too.
SetAutomatic (Required: ServiceName Optional: MachineName)
SetManual (Required: ServiceName Optional: MachineName)
Start (Required: ServiceName or Services Optional: MachineName, RetryAttempts)
Stop (Required: ServiceName or Services Optional: MachineName, RetryAttempts)
Uninstall (Required: ServicePath Optional: MachineName, RemoteUser, RemoteUserPassword)
UpdateIdentity (Required: ServiceName, User, Password Optional: MachineName)
Remote Execution Support: Yes
MSBuild.ExtensionPackBaseTask
MSBuild.ExtensionPack.ComputerWindowsService
Namespace: MSBuild.ExtensionPack.Computer
Assembly: MSBuild.ExtensionPack (in MSBuild.ExtensionPack.dll) Version: 4.0.0.0
The WindowsService type exposes the following members.
Name | Description | |
---|---|---|
WindowsService |
Name | Description | |
---|---|---|
CommandLineArguments |
Sets the command line arguments to be passed to the service.
| |
Description |
Sets the service description
| |
Exists |
Gets whether the service exists
| |
Force |
Sets a value indicating whether to delete a service if it already exists when calling Install
| |
Password |
Sets user password
| |
RemoteUser |
Sets the user to impersonate on remote server.
| |
RemoteUserPassword |
Sets the password for the user to impersonate on remote server.
| |
RetryAttempts |
Sets the number of times to attempt Starting / Stopping a service. Default is 60.
| |
ServiceDependencies |
Sets the services upon which the installed service depends.
| |
ServiceDisplayName |
The Display Name of the service. Defaults to ServiceName.
| |
ServiceName |
The Name of the service. Note, this is the 'Service Name' as displayed in services.msc, NOT the 'Display Name'
| |
ServicePath |
Sets the path of the service executable
| |
Services |
Sets the collection of Services to target in parallel. See TaskAction parameters for which TaskActions support this.
| |
StartupType |
Sets the Startup Type of the service.
| |
User |
Sets the user.
|
<Project ToolsVersion="4.0" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <TPath>$(MSBuildProjectDirectory)\..\MSBuild.ExtensionPack.tasks</TPath> <TPath Condition="Exists('$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks')">$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks</TPath> <User>serviceAcct</User> <Password>P2ssw0rd</Password> <RemoteMachine>VSTS2008</RemoteMachine> <RemoteUser>vsts2008\tfssetup</RemoteUser> <RemoteUserPassword>1Setuptfs</RemoteUserPassword> </PropertyGroup> <Import Project="$(TPath)"/> <Target Name="Default"> <!-- check whether a service exists (this should return true in most cases) --> <MSBuild.ExtensionPack.Computer.WindowsService TaskAction="CheckExists" ServiceName="Schedule"> <Output TaskParameter="Exists" PropertyName="DoesExist"/> </MSBuild.ExtensionPack.Computer.WindowsService> <Message Text="Schedule service exists: $(DoesExist)"/> <!-- check whether another service exists (this should return false)--> <MSBuild.ExtensionPack.Computer.WindowsService TaskAction="CheckExists" ServiceName="ThisServiceShouldNotExist"> <Output TaskParameter="Exists" PropertyName="DoesExist"/> </MSBuild.ExtensionPack.Computer.WindowsService> <Message Text="ThisServiceShouldNotExist service exists: $(DoesExist)"/> <!-- Check whether a service exists on a Remote Machine(this should return true in most cases) --> <MSBuild.ExtensionPack.Computer.WindowsService TaskAction="CheckExists" ServiceName="Schedule" RemoteUser="$(RemoteUser)" RemoteUserPassword="$(RemoteUserPassword)" MachineName="$(RemoteMachine)"> <Output TaskParameter="Exists" PropertyName="DoesExist"/> </MSBuild.ExtensionPack.Computer.WindowsService> <Message Text="Schedule service exists on '$(RemoteMachine)': $(DoesExist)"/> <!-- Start a service --> <MSBuild.ExtensionPack.Computer.WindowsService TaskAction="Start" ServiceName="MSSQLSERVER"/> <!-- Start a service on a Remote Machine --> <MSBuild.ExtensionPack.Computer.WindowsService TaskAction="Start" ServiceName="BITS" RemoteUser="$(RemoteUser)" RemoteUserPassword="$(RemoteUserPassword)" MachineName="$(RemoteMachine)" /> <!-- Stop a service --> <MSBuild.ExtensionPack.Computer.WindowsService TaskAction="Stop" ServiceName="MSSQLSERVER"/> <!-- Stop a service on a Remote Machine --> <MSBuild.ExtensionPack.Computer.WindowsService TaskAction="Stop" ServiceName="BITS" RemoteUser="$(RemoteUser)" RemoteUserPassword="$(RemoteUserPassword)" MachineName="$(RemoteMachine)"/> <!-- Uninstall a service on the Local Machine --> <MSBuild.ExtensionPack.Computer.WindowsService TaskAction="Uninstall" ServiceName="__TestService1" ServicePath="c:\WINDOWS\system32\taskmgr.exe" /> <!-- Uninstall a service on a Remote Machine --> <MSBuild.ExtensionPack.Computer.WindowsService TaskAction="Uninstall" ServiceName="__TestService1" ServicePath="c:\WINDOWS\system32\taskmgr.exe" RemoteUser="$(RemoteUser)" RemoteUserPassword="$(RemoteUserPassword)" MachineName="$(RemoteMachine)" /> <!-- Install a service on the Local machine --> <MSBuild.ExtensionPack.Computer.WindowsService TaskAction="Install" ServiceName="__TestService1" User="$(User)" Password="$(password)" ServicePath="c:\WINDOWS\system32\taskmgr.exe" /> <!-- Install a service on a Remote Machine --> <MSBuild.ExtensionPack.Computer.WindowsService TaskAction="Install" ServiceName="__TestService1" User="$(User)" Password="$(password)" ServicePath="c:\WINDOWS\system32\taskmgr.exe" RemoteUser="$(RemoteUser)" RemoteUserPassword="$(RemoteUserPassword)" MachineName="$(RemoteMachine)" /> <!-- Disable a service --> <MSBuild.ExtensionPack.Computer.WindowsService TaskAction="Disable" ServiceName="__TestService1"/> <!-- Disable a service on a Remote Machine --> <MSBuild.ExtensionPack.Computer.WindowsService TaskAction="Disable" ServiceName="__TestService1" RemoteUser="$(RemoteUser)" RemoteUserPassword="$(RemoteUserPassword)" MachineName="$(RemoteMachine)"/> <!-- Set a service to start automatically on system startup--> <MSBuild.ExtensionPack.Computer.WindowsService TaskAction="SetAutomatic" ServiceName="__TestService1"/> <!-- Set a service to start automatically on system startup on a Remote Machine --> <MSBuild.ExtensionPack.Computer.WindowsService TaskAction="SetAutomatic" ServiceName="__TestService1" RemoteUser="$(RemoteUser)" RemoteUserPassword="$(RemoteUserPassword)" MachineName="$(RemoteMachine)"/> <!-- Set a service to start manually --> <MSBuild.ExtensionPack.Computer.WindowsService TaskAction="SetManual" ServiceName="__TestService1"/> <!-- Set a service to start manually on a Remote Machine --> <MSBuild.ExtensionPack.Computer.WindowsService TaskAction="SetManual" ServiceName="__TestService1" RemoteUser="$(RemoteUser)" RemoteUserPassword="$(RemoteUserPassword)" MachineName="$(RemoteMachine)"/> <!-- Update the Identity that the service runs in --> <MSBuild.ExtensionPack.Computer.WindowsService TaskAction="UpdateIdentity" ServiceName="__TestService1" User="$(User)" Password="$(Password)"/> <!-- Update the Identity that the service on a Remote Machine runs in --> <MSBuild.ExtensionPack.Computer.WindowsService TaskAction="UpdateIdentity" ServiceName="__TestService1" User="$(User)" Password="$(Password)" RemoteUser="$(RemoteUser)" RemoteUserPassword="$(RemoteUserPassword)" MachineName="$(RemoteMachine)"/> </Target> </Project>