Class WinServices
- java.lang.Object
-
- com.install4j.api.windows.service.WinServices
-
public class WinServices extends java.lang.ObjectCollection of static methods to manipulate Windows services
-
-
Constructor Summary
Constructors Constructor Description WinServices()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidchange(java.lang.String serviceName, ServiceConfiguration configuration)Changes a service configuration.static java.lang.StringgetBinary(java.lang.String serviceName)Returns the registered binary of a service.static ServiceStartTypegetStartType(java.lang.String serviceName)Returns the start type of a service.static voidinstall(java.lang.String serviceName, ServiceConfiguration configuration)Installs a service.static booleanisRunning(java.lang.String serviceName)Checks if a service is currently running.static voidstart(java.lang.String serviceName, java.lang.String... parameters)Starts a service.static voidstop(java.lang.String serviceName)Stops a service.static voiduninstall(java.lang.String serviceName)Uninstalls a service.
-
-
-
Method Detail
-
start
public static void start(java.lang.String serviceName, java.lang.String... parameters) throws ServiceExceptionStarts a service. To successfully call this methods you have to request privileges first.- Parameters:
serviceName- the name of the serviceparameters- optional parameters- Throws:
ServiceException- aServiceNotFoundExceptionin case serviceName does not refer to the existing service, anServiceAccessExceptionif you don't have sufficient privileges or a generic exception with a Win32 error code
-
stop
public static void stop(java.lang.String serviceName) throws ServiceExceptionStops a service. To successfully call this methods you have to request privileges first.- Parameters:
serviceName- the name of the service- Throws:
ServiceException- aServiceNotFoundExceptionin case serviceName does not refer to the existing service, anServiceAccessExceptionif you don't have sufficient privileges or a generic exception with a Win32 error code
-
install
public static void install(java.lang.String serviceName, ServiceConfiguration configuration) throws ServiceExceptionInstalls a service. To successfully call this methods you have to request privileges first.- Parameters:
serviceName- the name of the serviceconfiguration- the configuration of the service. At least the binaryName property must be set.- Throws:
ServiceException- anServiceAccessExceptionif you don't have sufficient privileges or a generic exception with a Win32 error code
-
change
public static void change(java.lang.String serviceName, ServiceConfiguration configuration) throws ServiceExceptionChanges a service configuration. To successfully call this methods you have to request privileges first.- Parameters:
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.- Throws:
ServiceException- aServiceNotFoundExceptionin case serviceName does not refer to the existing service, anServiceAccessExceptionif you don't have sufficient privileges or a generic exception with a Win32 error code
-
uninstall
public static void uninstall(java.lang.String serviceName) throws ServiceExceptionUninstalls a service. To successfully call this methods you have to request privileges first.- Parameters:
serviceName- the name of the service- Throws:
ServiceException- aServiceNotFoundExceptionin case serviceName does not refer to the existing service, anServiceAccessExceptionif you don't have sufficient privileges or a generic exception with a Win32 error code
-
isRunning
public static boolean isRunning(java.lang.String serviceName) throws ServiceExceptionChecks if a service is currently running.- Parameters:
serviceName- the name of the service- Returns:
- true if running
- Throws:
ServiceException- aServiceNotFoundExceptionin case serviceName does not refer to the existing service, anServiceAccessExceptionif you don't have sufficient privileges or a generic exception with a Win32 error code
-
getStartType
public static ServiceStartType getStartType(java.lang.String serviceName) throws ServiceException
Returns the start type of a service.- Parameters:
serviceName- the name of the service- Returns:
- a
ServiceStartTypevalue - Throws:
ServiceException- aServiceNotFoundExceptionin case serviceName does not refer to the existing service, anServiceAccessExceptionif you don't have sufficient privileges or a generic exception with a Win32 error code
-
getBinary
public static java.lang.String getBinary(java.lang.String serviceName) throws ServiceExceptionReturns the registered binary of a service.- Parameters:
serviceName- the name of the service- Returns:
- the binary name. Can include quotes and arguments if the service was registered like this..
- Throws:
ServiceException- aServiceNotFoundExceptionin case serviceName does not refer to the existing service, anServiceAccessExceptionif you don't have sufficient privileges or a generic exception with a Win32 error code
-
-