Through my desktop application's installer (C# code), I want to execute an external process. I do so using the following code.
ProcessStartInfo sinfo = new ProcessStartInfo();
sinfo.FileName = filePath;
sinfo.WorkingDirectory = workingDir;
sinfo.UseShellExecute = false;
using (Process proc = Process.Start(sinfo))
{
proc.WaitForExit();
int code = proc.ExitCode;
}
My external process is basically trying to read a registry entry and process something with it (It only reads, does not write to the reg).
While I confirm that the registry entry values have already been updated by the installer (and I can manually read the reg entries through regedit), the external process is not able to read these. Its trying to read as follows:
using (RegistryKey rk = Registry.CurrentUser.OpenSubKey(regKey))
{
return (string)rk.GetValue(subKey);
}
When I put a breakpoint at the above lines, I see that rk has no subkeys inside it. I am doing all this in Win7 env (dont know if the UAC is causing the troubles)
Now, when I directly run the external app manually (i.e double click the app's exe), I am able to read the reg entries easily. Seems like I am doing something wrong while starting the process. Anybody has any ideas what?
Thanks, Kapil