|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.gridsystems.windowsutils.WindowsUtils
public final class WindowsUtils
MS Windows service management.
Method Summary | |
---|---|
static void |
addUserPrivilege(java.lang.String hostName,
java.lang.String user,
java.lang.String privilege)
Adds a specific privilege to a user. |
static boolean |
checkAdministrator()
Tells if the user executing the program has administrator rights. |
static boolean |
checkWindowsUser(java.lang.String user)
Chequeo de usuarios en XP y NT. |
static void |
createWindowsService(java.lang.String servicename,
java.lang.String executable,
java.lang.String user,
java.lang.String pass)
Installs a windows service allowing to set a specific user account. |
static java.lang.String |
getServiceStartUser(java.lang.String serviceName)
Gets the name of the user on whose account the service starts. |
static void |
removeWindowsService(java.lang.String servicename)
Elimina un Servicio Windows. |
static boolean |
serviceExists(java.lang.String serviceName)
Tells if a service with the specified name exists. |
static boolean |
startService(java.lang.String serviceName,
java.lang.String[] arguments,
boolean errorIfRunning)
Starts a service. |
static boolean |
stopService(java.lang.String serviceName,
boolean errorIfStopped)
Stops a service. |
static boolean |
userHasPrivilege(java.lang.String user,
java.lang.String privilege)
Checks if an user has a permission. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void createWindowsService(java.lang.String servicename, java.lang.String executable, java.lang.String user, java.lang.String pass) throws java.lang.Exception
servicename
- a String with the name of the service.executable
- a String with the path to the executable file.user
- a String with the user account to run the service with. If
null or empty, the service is set to run as a system service. If an user
account is specified, it is checked that startst with ".\" and, if it does
not, ".\" is added at the beginning of the user account.pass
- a String with the password of the account used to run the
service, if it is an user account.
java.lang.Exception
- with an human-readable message if any of the
parameters was wrong or if the native process to install the service
failed.public static void removeWindowsService(java.lang.String servicename) throws java.lang.Exception
servicename
- the service name
java.lang.Exception
- if errorpublic static void addUserPrivilege(java.lang.String hostName, java.lang.String user, java.lang.String privilege) throws java.lang.Exception
hostName
- Host nameuser
- User nameprivilege
- Privilege name
java.lang.Exception
- if errorpublic static boolean userHasPrivilege(java.lang.String user, java.lang.String privilege) throws java.lang.Exception
user
- a String with the username that is checked.privilege
- a String with the permission being checked.
java.lang.Exception
- if errorpublic static boolean checkWindowsUser(java.lang.String user) throws java.lang.Exception
user
- el usuario.
java.lang.Exception
- if errorpublic static boolean startService(java.lang.String serviceName, java.lang.String[] arguments, boolean errorIfRunning)
serviceName
- a String with the name of the service to start.arguments
- a String[] with the list of argument to pass to the
service.errorIfRunning
- a boolean that is true if the method should consider
that the service is already running as an error.
errorIfRunning
is false, if the service was
already running.public static boolean stopService(java.lang.String serviceName, boolean errorIfStopped)
serviceName
- a String with the name of the service to stop.errorIfStopped
- a boolean that is true if the method should consider
that the service is already stopped or stopping as an error.
errorIfStopped
is false,
if it was already stopped or stopping.public static boolean serviceExists(java.lang.String serviceName) throws java.lang.Exception
serviceName
- a String with the name of the service.
java.lang.Exception
- if an error happened when getting the installed
services.public static boolean checkAdministrator() throws java.lang.Exception
java.lang.Exception
- if an error happened when getting the information.public static java.lang.String getServiceStartUser(java.lang.String serviceName) throws java.lang.Exception
serviceName
- the name of the service being checked.
java.lang.Exception
- in case of error.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |