Hello!
I'm working on some application which has auto-update function. The implemented idea is simple as following:
- There are some "starter" application which is installed to "Program Files/whatever/...". It's the application which is intended to be started by user.
- Each time the "starter" application is executed it checks server for updates and downloads it to "%APPDATA%/some/...". And then it starts some application from that folder.
Above approach is working on my development machine (running Vista) and on some other machines under XP, but under some different machine (running Windows 7) it isn't working. When "starter" executes the real application it crashes with some unknown problem (Signature = System.UnauthorizedAccess). When real application is executed manually from %APPDATA%/some/ folder then everything is working fine. I've tried to set same working directory in ProcessStartInfo, so "starter" will also execute real application in that folder, but this isn't helped me.
How can I diagnose and/or fix that issue?
Update
More details on how I'm running main process from starter:
private static readonly string _ROOT = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MyApp");
...
private static void Run()
{
string startPath = Path.Combine(_ROOT, "MyApp.exe");
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = startPath;
startInfo.WorkingDirectory = _ROOT;
Process.Start(startPath);
}
This surely starts the correct process because application window can be seen, but some disk or network operation is probably denied by Windows and started process is crashed.
Update
The tracing shown that working directory wasn't correct and that pointed to incorrect Process.Start(string) method call in my code. The correct line:
Process.Start(startInfo);