add name/password fields to ServiceConfig so it can be used to create services
This commit is contained in:
parent
82a5ad05ab
commit
a0017f6dca
|
@ -74,6 +74,7 @@ public class Service extends Win32 {
|
||||||
|
|
||||||
private long manager;
|
private long manager;
|
||||||
private long service;
|
private long service;
|
||||||
|
private String name;
|
||||||
|
|
||||||
private Service() throws Win32Exception
|
private Service() throws Win32Exception
|
||||||
{
|
{
|
||||||
|
@ -96,6 +97,8 @@ public class Service extends Win32 {
|
||||||
if (this.service == 0) {
|
if (this.service == 0) {
|
||||||
throw getLastErrorException();
|
throw getLastErrorException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.name = serviceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void finalize()
|
protected void finalize()
|
||||||
|
@ -297,6 +300,7 @@ public class Service extends Win32 {
|
||||||
if (!QueryServiceConfig(this.service, config)) {
|
if (!QueryServiceConfig(this.service, config)) {
|
||||||
throw getLastErrorException();
|
throw getLastErrorException();
|
||||||
}
|
}
|
||||||
|
config.setName(this.name);
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,11 +78,27 @@ public class ServiceConfig {
|
||||||
String binaryPathName;
|
String binaryPathName;
|
||||||
String loadOrderGroup;
|
String loadOrderGroup;
|
||||||
int tagId;
|
int tagId;
|
||||||
String[] dependencies = null;
|
String[] dependencies;
|
||||||
String serviceStartName;
|
String serviceStartName;
|
||||||
String displayName;
|
String displayName;
|
||||||
String description;
|
String description;
|
||||||
|
String password;
|
||||||
|
String name;
|
||||||
|
|
||||||
|
ServiceConfig() {}
|
||||||
|
|
||||||
|
public ServiceConfig(String name) {
|
||||||
|
this.name = name;
|
||||||
|
this.type = TYPE_WIN32_OWN_PROCESS;
|
||||||
|
this.startType = START_AUTO;
|
||||||
|
this.errorControl = ERROR_NORMAL;
|
||||||
|
//msdn docs:
|
||||||
|
//"Specify an empty string if the account has no password
|
||||||
|
//or if the service runs in the LocalService, NetworkService,
|
||||||
|
//or LocalSystem account"
|
||||||
|
this.password = "";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the binaryPathName.
|
* @return Returns the binaryPathName.
|
||||||
*/
|
*/
|
||||||
|
@ -206,4 +222,28 @@ public class ServiceConfig {
|
||||||
public void setDescription(String description) {
|
public void setDescription(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @return Returns the password.
|
||||||
|
*/
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param password The password to set.
|
||||||
|
*/
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return Returns the name.
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param name The name to set.
|
||||||
|
*/
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue