Use registry to startup a program, and also change the current working directory?
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);
You can also create a shortcut for the program in the folder and reference this shortcut in the registry:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
Name: example
Type: REG_SZ
Data: "C:\example\example.lnk
At the start of the application, do the following (this is C#, convert to C++):
using System.IO;
:
:
Environment.CurrentDirectory = Path.GetDirectoryName(Application.ExecutablePath);