I successfully passed parameters from Installutil to my service technician, but I cannot pass these parameters to Main (string [args]). This is how I try to do it .... if there is a better way to do what I do, please let me know
protected override void OnAfterInstall(IDictionary savedState)
{
base.OnAfterInstall(savedState);
string[] args = new string[2];
args[0] = Context.Parameters["username"];
args[0] = Context.Parameters["password"];
new ServiceController(this.dataLoaderServiceInstaller.ServiceName).Start(args);
}
and this is my program.cs
static void Main(string[] args)
{
TextWriter tw = new StreamWriter(@"c:\\bw\\date.txt");
tw.WriteLine(args.Length);
tw.Close();
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new DataloaderService()
};
ServiceBase.Run(ServicesToRun);
}
the length of the strokes I am trying to record is always zero. One more question will this parameter remain after rebooting the computer / server for maintenance? Thanks in advance.:)
source
share