public class WinServices
extends java.lang.Object
Constructor and Description |
---|
WinServices() |
Modifier and Type | Method and Description |
---|---|
static void |
change(java.lang.String serviceName,
ServiceConfiguration configuration)
Changes a service configuration.
|
static java.lang.String |
getBinary(java.lang.String serviceName)
Returns the registered binary of a service.
|
static ServiceStartType |
getStartType(java.lang.String serviceName)
Returns the start type of a service.
|
static void |
install(java.lang.String serviceName,
ServiceConfiguration configuration)
Installs a service.
|
static boolean |
isRunning(java.lang.String serviceName)
Checks if a service is currently running.
|
static void |
start(java.lang.String serviceName,
java.lang.String... parameters)
Starts a service.
|
static void |
stop(java.lang.String serviceName)
Stops a service.
|
static void |
uninstall(java.lang.String serviceName)
Uninstalls a service.
|
public static void start(java.lang.String serviceName, java.lang.String... parameters) throws ServiceException
serviceName
- the name of the serviceparameters
- optional parametersServiceException
- a ServiceNotFoundException
in case serviceName does not refer to the existing service,
an ServiceAccessException
if you don't have sufficient privileges or a generic exception with a Win32 error codepublic static void stop(java.lang.String serviceName) throws ServiceException
serviceName
- the name of the serviceServiceException
- a ServiceNotFoundException
in case serviceName does not refer to the existing service,
an ServiceAccessException
if you don't have sufficient privileges or a generic exception with a Win32 error codepublic static void install(java.lang.String serviceName, ServiceConfiguration configuration) throws ServiceException
serviceName
- the name of the serviceconfiguration
- the configuration of the service. At least the binaryName property must be set.ServiceException
- an ServiceAccessException
if you don't have sufficient privileges or a generic exception with a Win32 error codepublic static void change(java.lang.String serviceName, ServiceConfiguration configuration) throws ServiceException
serviceName
- the name of the serviceconfiguration
- the configuration of the service. All properties that are not set or set to null won't be changed.ServiceException
- a ServiceNotFoundException
in case serviceName does not refer to the existing service,
an ServiceAccessException
if you don't have sufficient privileges or a generic exception with a Win32 error codepublic static void uninstall(java.lang.String serviceName) throws ServiceException
serviceName
- the name of the serviceServiceException
- a ServiceNotFoundException
in case serviceName does not refer to the existing service,
an ServiceAccessException
if you don't have sufficient privileges or a generic exception with a Win32 error codepublic static boolean isRunning(java.lang.String serviceName) throws ServiceException
serviceName
- the name of the serviceServiceException
- a ServiceNotFoundException
in case serviceName does not refer to the existing service,
an ServiceAccessException
if you don't have sufficient privileges or a generic exception with a Win32 error codepublic static ServiceStartType getStartType(java.lang.String serviceName) throws ServiceException
serviceName
- the name of the serviceServiceStartType
valueServiceException
- a ServiceNotFoundException
in case serviceName does not refer to the existing service,
an ServiceAccessException
if you don't have sufficient privileges or a generic exception with a Win32 error codepublic static java.lang.String getBinary(java.lang.String serviceName) throws ServiceException
serviceName
- the name of the serviceServiceException
- a ServiceNotFoundException
in case serviceName does not refer to the existing service,
an ServiceAccessException
if you don't have sufficient privileges or a generic exception with a Win32 error code