Two questions.
1) I followed Walkthrough of Win Service App. At the end, when I run Setup
it complains about incorrect user and/or password. Where does it look for
userid? I have logged in as Administrator.
2) Why cannot I install the service with ServiceName.exe /install command as
I do for non-dotNet service?
You can but you have to write it.
If you look in a C++ service you'll see it has a load of code under
the /install (/service)
It's a lot easier in .Net though
Here is a C# version of what you want
You need this as the first thing in your Main function
Vin
// if we have an argument process it
if (args.Length > 0)
{
string sSwitch = args[0];
sSwitch.ToLower();
switch (sSwitch.Substring(0, 1))
{
case "-":
case "/":
case @"\":
{
sSwitch = sSwitch.Substring(1);
break;
}
}
string sExe = typeof(RAPIDHouseKeeper).Assembly.Location;
string sInstallUtil = typeof(object).Assembly.Location;
sInstallUtil = sInstallUtil.Substring(0,
sInstallUtil.LastIndexOf(@"\"));
sInstallUtil += @"\InstallUtil.exe";
AppDomain dom = AppDomain.CreateDomain("execDom");
switch (sSwitch)
{
case "install":
case "regserver":
case "service":
{
// uninstall before installing (in case it's
pointing to the wrong place)
string[] asUninstallArgs = new string[2]
{"/u", sExe};
dom.ExecuteAssembly(sInstallUtil, null,
asUninstallArgs);
// now install
string[] asArgs = new string[1] {sExe};
dom.ExecuteAssembly(sInstallUtil, null,
asArgs);
return;
}
case "uninstall":
case "unregserver":
{
string[] asArgs = new string[2] {"/u", sExe};
dom.ExecuteAssembly(sInstallUtil, null,
asArgs);
return;
}
}
}