Reputation: 21
We have created an application that changes the .ini files for a 3rd party app, so users at the enterprise level can access the various environments we have installed. This worked fine for us while using windows XP. I recently set out to make the application more windows 7 friendly, and look for the 3rd party app .ini file under c:\users\public.
The 3rd party app is installed and functioning correctly, but when we run the code below from a windows 7 machine it complains that it can not find its .ini files.
manager.EnableRaisingEvents = true;
manager.StartInfo.FileName = iniChange.getBinPath() + "\\eimngr.exe";
manager.Start();
appOpen++;
magOpen++;
I am wondering if we have missed setting some property of StartInfo or the Process.
Upvotes: 2
Views: 212
Reputation: 17030
My best guess is that the target application can not find the INI-file cause it uses relative pathes internally. Try to set the working directory explicitly:
string targetFilePath = @"c:\folder\another_folder\myapp.exe";
string targetWorkingDirectory = System.IO.Path.GetDirectoryName(targetFilePath);
ProcessStartInfo startInfo = new ProcessStartInfo()
{
WorkingDirectory = targetWorkingDirectory,
FileName = targetFilePath,
};
Process targetProcess = new Process();
targetProcess.StartInfo = startInfo;
targetProcess.EnableRaisingEvents = true;
// ...
targetProcess.Start();
Upvotes: 1