public class MyService: ServiceControl
{
public static int Main(string[] args)
{
DecodePasswords(args);
var host = HostFactory.New(x =>
{
x.Service<MyService>(hostSettings => new MyService(hostSettings));
});
return OkStatuses.Contains(exitCode) ? 0 : (int)exitCode;
}
private static bool IsInstalling(string[] args)
{
return (args.Length > 2) && (args[0].ToUpper() == "INSTALL");
}
private static void DecodePasswords(string[] args)
{
if (IsInstalling(args))
{
var encryptedPassword = string.Empty;
for (int i = 1; i < args.Length; i++)
{
var arg = args[i].Trim().ToUpper();
if (arg == "-PASSWORD" && ((i + 1 < args.Length)))
{
encryptedPassword = args[i + 1];
try
{
args[i + 1] = DecodePassword(encryptedPassword);
Console.WriteLine(args[i + 1]); //TODO TEMP
}
catch
{
//ignore
break;
}
break;
}
}
}
}
}
I've checked the arguments and decoded password and they are correct, but when I start the service the following error occurs:
The MyService service failed to start due to the following error:
The service did not start due to a log-on failure.
The MyService service was unable to log on as .\MyServiceUser with the currently configured password due to the following error:
The username or password is incorrect.
I've tried BeforeInstall but HostSettings but contains the ServiceName etc. but not the Password.