Use registry to startup a program, and also change the current working directory?
Solution 1:
You can register your application under next registry key (like this does Reg2Run tool)
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\App Paths\example.exe
@="c:\example\example.exe"
Path="c:\AnotherPath"
So System.Diagnostics.Run("example.exe");
will launch your application with specified working path.
Or another way: write a launcher using C#. You can do the same using a PowerShell cmdlet.
var info = new System.Diagnostics.ProcessStartInfo(@"c:\example\example.exe", "-someargument")
{
WorkingDirectory = @"c:\AnotherPath"
};
System.Diagnostics.Process.Start(info);
Solution 2:
At the start of the application, do the following (this is C#, convert to C++):
using System.IO;
:
:
Environment.CurrentDirectory = Path.GetDirectoryName(Application.ExecutablePath);