I have a windows service that is deployed using a VS2010 deployment project. I require that a username/password be entered in the installer and then these details commited to the registry for the service to use.
The installer works fine, and the custom actions are setup correctly. If i try to commt to HKLM i get no error but no output either, the same command to HKCU works fine. This is the same as both a standard and administrative user (including RunAs).
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
var username = Context.Parameters["username"];
var password = Context.Parameters["password"];
// HKLM\Software\MySoftware
RegistryKey hklm = Registry.LocalMachine.CreateSubKey("SOFTWARE\\MySoftware");
hklm.SetValue("username", username, RegistryValueKind.String);
hklm.SetValue("password", password, RegistryValueKind.String);
hklm.Close();
// HKCU\Software\MySoftware
RegistryKey hkcu = Registry.CurrentUser.CreateSubKey("SOFTWARE\\MySoftware");
hkcu.SetValue("username", username, RegistryValueKind.String);
hkcu.SetValue("password", password, RegistryValueKind.String);
hkcu.Close();
}
I have tried using .OpenSubkey(x, true) instead of CreateSubkey(x). The results are the same.
Any help would be greatly appriciated.
Regards
Chris