Class WinServices
java.lang.Object
com.install4j.api.windows.service.WinServices
Collection of static methods to manipulate Windows services
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidchange(String serviceName, ServiceConfiguration configuration) Changes a service configuration.static StringReturns the registered binary of a service.static ServiceStartTypegetStartType(String serviceName) Returns the start type of a service.static voidinstall(String serviceName, ServiceConfiguration configuration) Installs a service.static booleanChecks if a service is currently running.static voidStarts a service.static voidStops a service with a default timeout of 30s.static voidStops a service.static voidUninstalls a service.
- 
Constructor Details- 
WinServicespublic WinServices()
 
- 
- 
Method Details- 
startStarts a service. To successfully call this method, you have to request privileges first.- Parameters:
- serviceName- the name of the service
- parameters- optional parameters
- Throws:
- ServiceException- a- ServiceNotFoundExceptionin case serviceName does not refer to the existing service, an- ServiceAccessExceptionif you don't have sufficient privileges or a generic exception with a Win32 error code
 
- 
stopStops a service with a default timeout of 30s.- Throws:
- ServiceException
- See Also:
 
- 
stopStops a service. To successfully call this method, you have to request privileges first.- Parameters:
- serviceName- the name of the service
- minimumWaitTime- the minimum time in milliseconds that will be waited for the service to shut down.
- Throws:
- ServiceException- a- ServiceNotFoundExceptionin case serviceName does not refer to the existing service, an- ServiceAccessExceptionif you don't have sufficient privileges or a generic exception with a Win32 error code
 
- 
installpublic static void install(String serviceName, ServiceConfiguration configuration) throws ServiceException Installs a service. To successfully call this method, you have to request privileges first.- Parameters:
- serviceName- the name of the service
- configuration- the configuration of the service. At least the binaryName property must be set.
- Throws:
- ServiceException- an- ServiceAccessExceptionif you don't have sufficient privileges or a generic exception with a Win32 error code
 
- 
changepublic static void change(String serviceName, ServiceConfiguration configuration) throws ServiceException Changes a service configuration. To successfully call this method, you have to request privileges first.- Parameters:
- serviceName- the name of the service
- configuration- the configuration of the service. All properties that are not set or set to- nullwon't be changed.
- Throws:
- ServiceException- a- ServiceNotFoundExceptionin case serviceName does not refer to the existing service, an- ServiceAccessExceptionif you don't have sufficient privileges or a generic exception with a Win32 error code
 
- 
uninstallUninstalls a service. To successfully call this method, you have to request privileges first.- Parameters:
- serviceName- the name of the service
- Throws:
- ServiceException- a- ServiceNotFoundExceptionin case serviceName does not refer to the existing service, an- ServiceAccessExceptionif you don't have sufficient privileges or a generic exception with a Win32 error code
 
- 
isRunningChecks if a service is currently running.- Parameters:
- serviceName- the name of the service
- Returns:
- trueif running
- Throws:
- ServiceException- a- ServiceNotFoundExceptionin case serviceName does not refer to the existing service, an- ServiceAccessExceptionif you don't have sufficient privileges or a generic exception with a Win32 error code
 
- 
getStartTypeReturns the start type of a service.- Parameters:
- serviceName- the name of the service
- Returns:
- a ServiceStartTypevalue
- Throws:
- ServiceException- a- ServiceNotFoundExceptionin case serviceName does not refer to the existing service, an- ServiceAccessExceptionif you don't have sufficient privileges or a generic exception with a Win32 error code
 
- 
getBinaryReturns 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- a- ServiceNotFoundExceptionin case serviceName does not refer to the existing service, an- ServiceAccessExceptionif you don't have sufficient privileges or a generic exception with a Win32 error code
 
 
-