.NET Framework Bookmark and Share   
 index > .NET Base Class Library > Urgent: Run an EXE file with process?
 

Urgent: Run an EXE file with process?

Dear,
I have a file "c:\1.exe" when it load, I want him to run another file "c:\my\2.exe", which it calls some references from its path "c:\my".
Please I dont want to use process control for some references reasons. How can I open it directly without using process?
Thx in advanced.

Hassan Ayoub

How are you using the Process class?

If you want the "working directory" to be different when you execute a file, you can use the Process.Start(ProcessStartInfo) method and use the ProcessStartInfo.WorkingDirectory property. You can try overriding the working directory to see if that changes things, for example:

Code Block

ProcessStartInfo processStartInfo = new ProcessStartInfo(@"c:\my\2.exe");

processStartInfo.WorkingDirectory = @"C:\my";

Process p = Process.Start(processStartInfo);

Otherwise, you'll have to find out how these streams are being opened. If they're being opened based upon the assembly's location, there's nothing you can do about that from 1.exe...

Peter Ritchie
can u please ellobrate it bit

Manju Sandhu

Dear,

I have a file in "C:\my" called "2.exe" which load its methods from a DLL called "2.dll" found in the same place. Some of these methods is outpot stream which write some notes to a file in te same location too.

I created another application "1.exe", not in the same location, this application call the "2.exe" application.

If I use Process class, the stream writer right the file on the path of "1.exe" and not the original path of "2.exe" and the methods called by 2.exe from the dll not found.

I want to call the exe file without using process to prevent path mistakes.

Thx

Hassan Ayoub

How are you using the Process class?

If you want the "working directory" to be different when you execute a file, you can use the Process.Start(ProcessStartInfo) method and use the ProcessStartInfo.WorkingDirectory property. You can try overriding the working directory to see if that changes things, for example:

Code Block

ProcessStartInfo processStartInfo = new ProcessStartInfo(@"c:\my\2.exe");

processStartInfo.WorkingDirectory = @"C:\my";

Process p = Process.Start(processStartInfo);

Otherwise, you'll have to find out how these streams are being opened. If they're being opened based upon the assembly's location, there's nothing you can do about that from 1.exe...

Peter Ritchie
No matter what method you use for executing the exe, it will create another process to execute it in, so you will probably have the same problem anyway. You need to set the WorkingDirectory property of the ProcessStartInfo object that you use to start "2.exe". That should fix your problem.
Nimrand

Thx alot guys for your help, I will try this asap and seems that it will solve my problem.

I will keep you in touch if not.

Thx

Hassan Ayoub

You can use google to search for other answers

Custom Search

More Threads

• How to scan a document via front end application c#.net
• MMC SmallImages causes performance problem?
• SerialPort.ReadChar Query
• Sending content of file over serial connection.
• calls into dll through reflection fail because of lack of referenced assemblies
• What base class can I use when passing collections?
• Folder names
• How to set registry permission programatically?
• Diff Bet VS .net and VS
• Code Injection