Hi All!
After hours of searching the net, I found nothing really substantial
about this. For me, passing username and password from the commandline,
is not very unsecure, but there is no way described, how this can work.
Without preparation, a GUI appears, even user/pwd are specified on the
commandline. Naturally, I do not want to specify username and password
in the source [this would work].
I experimented with the installer classes and discovered their hierarchy
a little bit. I came to really ugly code in my service installer class,
but it works:
[RunInstaller(true)]
public class MyServiceInstaller:Installer
{
private ServiceInstaller serviceInst;
private ServiceProcessInstaller serviceProcessInst;
public MyServiceInstaller():base()
{
this.serviceProcessInst = new ServiceProcessInstaller();
this.serviceProcessInst.Account = ServiceAccount.User;
this.serviceProcessInst.Username = null;
this.serviceProcessInst.Password = null;
Installers.Add( ... )
}
public override void Install(IDictionary savedState)
{
if(base.Parent.Parent.Context.Parameters["username"] != null)
{
this.serviceProcessInst.Username =
base.Parent.Parent.Context.Parameters["username"];
}
if(base.Parent.Parent.Context.Parameters["password"] != null)
{
this.serviceProcessInst.Password =
base.Parent.Parent.Context.Parameters["password"];
}
base.Install(savedState);
}
}//class
I am interested to see better code ;-)
Thanks and
best regards,
mabra