Executing an exe with C# code
-
I am attempting to write some code that will execute one of my EXE's from another project. This other EXE file uses an INI file which is located in the same folder as the exe itself. But when I run the exe file using C# code, the exe creates a new default INI file here: C:\Documents and Settings\UserName\Local Settings\Application Data\Temporary Projects\KeepAlive\bin\Debug (this is the projects directory) How do I execute an exe in code asif it was simply a shorcut being double-clicked on the desktop? I have tried the following:
Process.Start(@ApplicationFullPath);
string str = (@ApplicationFullPath;
Process process = new Process();
process.StartInfo.FileName = str;
process.StartBoth of these solution had the same problem.
-
I am attempting to write some code that will execute one of my EXE's from another project. This other EXE file uses an INI file which is located in the same folder as the exe itself. But when I run the exe file using C# code, the exe creates a new default INI file here: C:\Documents and Settings\UserName\Local Settings\Application Data\Temporary Projects\KeepAlive\bin\Debug (this is the projects directory) How do I execute an exe in code asif it was simply a shorcut being double-clicked on the desktop? I have tried the following:
Process.Start(@ApplicationFullPath);
string str = (@ApplicationFullPath;
Process process = new Process();
process.StartInfo.FileName = str;
process.StartBoth of these solution had the same problem.
-
"C:\Program Files\Company\ApplicationPath"
so just to clarify. you have an apllication in C:\..\Application that you want to launch an applciation in C:\..\keepAlive\Bin\Debug. The application in debug is supposed to create an INI file in its location but instead it creates it in the location of the application that is loading it? (LOL maybe not so clear)
-
so just to clarify. you have an apllication in C:\..\Application that you want to launch an applciation in C:\..\keepAlive\Bin\Debug. The application in debug is supposed to create an INI file in its location but instead it creates it in the location of the application that is loading it? (LOL maybe not so clear)
Application A -> Located in Program Files, uses a INI file in it's "home directory" (Creates a default INI if none exists) Application B -> VisualStudio Project has code to startup application A, however, when B starts A, A looks for this INI file in Documents & Setting in the path where Application B's debug binaries etc are located. It doesn't find it and creates a default INI, but not in Program Files.
-
Application A -> Located in Program Files, uses a INI file in it's "home directory" (Creates a default INI if none exists) Application B -> VisualStudio Project has code to startup application A, however, when B starts A, A looks for this INI file in Documents & Setting in the path where Application B's debug binaries etc are located. It doesn't find it and creates a default INI, but not in Program Files.
Thats because when B starts A, A's startup path is set to B's home directory. Use the following algorithm in B to start A: 1. Change the directory where A resides. 2. Start A This should solve your problem.
Excuse me for buttin' in, but I'm interrupt driven.
-
Application A -> Located in Program Files, uses a INI file in it's "home directory" (Creates a default INI if none exists) Application B -> VisualStudio Project has code to startup application A, however, when B starts A, A looks for this INI file in Documents & Setting in the path where Application B's debug binaries etc are located. It doesn't find it and creates a default INI, but not in Program Files.
i assume app A uses applicationStartupPath to find where to put the INI, which when started from App B becomes the startup path of App B instead of where it was executed from. You could try passing a parameter to application A that tells it its startup path, but you would need to Modify App A to handle the parameter. Something like a global variable with the startupPath, then if paramter is present set it to the passed paramter otherwise use the Application.StartupPath when no paramter is passed
-
Thats because when B starts A, A's startup path is set to B's home directory. Use the following algorithm in B to start A: 1. Change the directory where A resides. 2. Start A This should solve your problem.
Excuse me for buttin' in, but I'm interrupt driven.
-
i assume app A uses applicationStartupPath to find where to put the INI, which when started from App B becomes the startup path of App B instead of where it was executed from. You could try passing a parameter to application A that tells it its startup path, but you would need to Modify App A to handle the parameter. Something like a global variable with the startupPath, then if paramter is present set it to the passed paramter otherwise use the Application.StartupPath when no paramter is passed