I have created an Utility.exe using C# which allows users to choose one of the multiple versions of an application. The user runs the Utility.exe and clocks on one of the version buttons in the Utility window which triggers a batch file for that version and then the respective application.exe.
The problem I am facing is after the Application.exe is triggered. The user logs into the application but gets the error Database Handle is Invalid.
But, when the user goes to the Application version folder and runs the batch file and then launches the application, it works fine.
My assumption is that when we trigger the batch file through the utility.exe, it does not discern the file path for the OCX and DLL files and thus does not register them properly.
A workaround is to specify the file path for the OCX and DLL files in each of the version batch files on each of the user's desktops.
Is there a way I can specify the file path in the utility code (C#) for the OCX and the DLL files mentioned in the batch file?
EDIT: I tried using process.StartInfo.WorkingDirectory as suggested by Dave but still getting the same issue.
private void button1_Click(object sender, EventArgs e)
{
string batDir = string.Concat(@"C:\Program Files (x86)\Blah\BlahBlah\batch.bat");
Process proc1 = new Process();
proc1.StartInfo.FileName = batDir;
proc1.StartInfo.WorkingDirectory = @"C:\Program Files (x86)\Blah\BlahBlah";
proc1.StartInfo.CreateNoWindow = false;
proc1.StartInfo.Verb = "runas";
proc1.Start();
proc1.WaitForExit();
string exeDir = string.Concat(@"C:\Program Files (x86)\Blah\BlahBlah\application.exe");
Process proc2 = new Process();
proc2.StartInfo.FileName = exeDir;
proc2.StartInfo.CreateNoWindow = false;
proc2.Start();
}
Hopefully, I have been able to articulate my problem.