Reputation: 14421
I have a system which includes an installer, a windows service and a configuration GUI program. The installer isn't your standard visual studio setup deployment project, but another program that I have coded. The installer launches the config program after the service is installed.
I've made a change to the config program that defaults a text box to a registry value in the HKEY_CURRENT_USER registry (which is from 3rd party software so I can't change the location of this value). This all works fine when I launch the config program from my start menu, however when the installer launches the program after it is complete, this value is not loaded from the registry.
Here's the code that launches the program after the installer has finished:
Process process = new Process();
process.StartInfo.FileName = Program.Installer.ConfigPath;
process.StartInfo.Arguments = Location.X.ToString() + " " + Location.Y.ToString();
process.Start();
while (!process.Responding)
Thread.Sleep(50);
Close();
Application.Exit();
Here's the code that gets the registry value:
_regKey = Registry.CurrentUser.OpenSubKey("Software\\" + _appName);
return _regKey.GetValue(key);
I've viewed both processes in task manager, and I can see no difference between the two at all. Both are being ran by the same user at the same path. The installer requires elevation, but I have elevated the config program separately and this has still worked.
Can anyone think of any other differences in a process that has been started by Windows and a process that has been called by another process?
Thanks,
Upvotes: 0
Views: 119
Reputation: 14421
Turns out that this was nothing to do with the registry at all. I moved my code around so that the registry value was loaded on the press of the "Next" button in the installer, rather than the start of the application. In my OnLoad function, there was a line which returns if a connection to a server was not initialised (which it wont be if it has not yet been set up at all). My code that was loading the value was AFTER this line of code and was therefore never being reached.
Just me being stupid.
Thanks
Upvotes: 0