Hello, perhaps I should be asking this in the MSDN forums, but i thought i'd give it a go here first.
I've got a Visual Studio Setup project, with some custom actions, one of these custom actions simply tries to set a registry key value in the HKEY_CURRENT_USER section after install...and then it executes an exe file. My code would look something similar to this
void InstallerClass_Committed(object sender, InstallEventArgs e)
{
RegistryUtility.SaveRegistryValue("CurrentVersion", 1.00);
Process.Start("myEXE.exe");
}
My RegistryUtility.SaveRegistryValue is something like this..
public static void SaveRegistryValue(string registryKey, string value)
{
RegistryKey masterKey = Registry.CurrentUser.CreateSubKey("SOFTWARE\\MySoftware\\Properties");
if (masterKey == null)
{
//i'm not sure how this happens..so ima leave it blank
}
else
{
try
{
masterKey.SetValue(registryKey, value);
}
catch (Exception ex)
{
//error handling not relevant to this post
}
finally
{
masterKey.Close();
}
}
}
Then when myEXE.exe loads, it also saves some registry values. The problem is, that when it saves these registry values...it's saving them under the Default Profile (HKEY_USER/.DEFAULT)...it does this both when I save registry values from the installer, and when it launches myEXE.exe for the first time. Everytime I launch myEXE.exe after that, it will use the intended HKEY_CURRENT_USER registry keys (it works as intended if
I launch myEXE.exe, as in not the installer launching it). This is a problem because I need to be able to read what I wrote during the installer, and the first time the application is run ect.
Any ideas on what I should do? I'm not a pro with installers, I know they get some kind of elevated privileges or run under some different settings or something, but is there a way I can still get access to the current users registry keys?
I tried launching myEXE with some ProcessStartInfo filled out like this
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = "myEXE.exe";
info.LoadUserProfile = true; //thought maybe this would do it for at least the myEXE.exe part..but nope
Process.Start(info);
but that did nothing. I'm a bit stuck here, and any pointers would be great.
Thanks