473,385 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problem with Process

Hello,
I am having issues when i use the Systsem.Diagnostics.Process
namespace to start a process. The problem is that i am able to succeed in
starting a process (an exe) only few times in a row from a windows
application before it fails throwing the following exception. (The exe i am
trying to run is in the same directory as the application.)

System.ComponentModel.Win32Exception
The system cannot find the file specified
System.ComponentModel.Win32Exception: The system cannot find the file
specified
at System.Diagnostics.Process.StartWithShellExecuteEx (ProcessStartInfo
startInfo)
at System.Diagnostics.Process.Start()

I have no idea why it would succeed the first few times and fail then. I am
posting the code i am am using.

System.Diagnostics.Process normComm = new System.Diagnostics.Process();
string pathEXE = "myprog.exe";
System.Diagnostics.ProcessStartInfo startInfo = new
System.Diagnostics.ProcessStartInfo(Environment.Cu rrentDirectory + @"\" +
pathEXE);
string args = "argument";
startInfo.WorkingDirectory = Environment.CurrentDirectory;
startInfo.Arguments = args;
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.CreateNoWindow = true;

normComm.StartInfo = startInfo;
try
{
normComm.Start(); //exception here

}

Any thoughts???Any help will be greatly appaerciated as i am unable to get a
breakthrough on this issue.

Thanks
Bala


Aug 22 '06 #1
2 9812
SP

"Bala Nagarajan" <ba********@newsgroups.nospamwrote in message
news:uP**************@TK2MSFTNGP06.phx.gbl...
Hello,
I am having issues when i use the Systsem.Diagnostics.Process
namespace to start a process. The problem is that i am able to succeed in
starting a process (an exe) only few times in a row from a windows
application before it fails throwing the following exception. (The exe i
am trying to run is in the same directory as the application.)

System.ComponentModel.Win32Exception
The system cannot find the file specified
System.ComponentModel.Win32Exception: The system cannot find the file
specified
at System.Diagnostics.Process.StartWithShellExecuteEx (ProcessStartInfo
startInfo)
at System.Diagnostics.Process.Start()

I have no idea why it would succeed the first few times and fail then. I
am posting the code i am am using.

System.Diagnostics.Process normComm = new System.Diagnostics.Process();
string pathEXE = "myprog.exe";
System.Diagnostics.ProcessStartInfo startInfo = new
System.Diagnostics.ProcessStartInfo(Environment.Cu rrentDirectory + @"\" +
pathEXE);
string args = "argument";
startInfo.WorkingDirectory = Environment.CurrentDirectory;
startInfo.Arguments = args;
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.CreateNoWindow = true;

normComm.StartInfo = startInfo;
try
{
normComm.Start(); //exception here

}

Any thoughts???Any help will be greatly appaerciated as i am unable to get
a breakthrough on this issue.
Perhaps current directory has changed. I believe that some of the dialog
boxes like open file change this and you can change it yourself as well. Use
Path.GetDirectoryName(Application.ExecutablePath) instead.

SP

Aug 23 '06 #2
Thanks for the response. I still face the problem.

Bala
"SP" <ec***********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>
"Bala Nagarajan" <ba********@newsgroups.nospamwrote in message
news:uP**************@TK2MSFTNGP06.phx.gbl...
>Hello,
I am having issues when i use the Systsem.Diagnostics.Process
namespace to start a process. The problem is that i am able to succeed in
starting a process (an exe) only few times in a row from a windows
application before it fails throwing the following exception. (The exe i
am trying to run is in the same directory as the application.)

System.ComponentModel.Win32Exception
The system cannot find the file specified
System.ComponentModel.Win32Exception: The system cannot find the file
specified
at System.Diagnostics.Process.StartWithShellExecuteEx (ProcessStartInfo
startInfo)
at System.Diagnostics.Process.Start()

I have no idea why it would succeed the first few times and fail then. I
am posting the code i am am using.

System.Diagnostics.Process normComm = new
System.Diagnostics.Process();
string pathEXE = "myprog.exe";
System.Diagnostics.ProcessStartInfo startInfo = new
System.Diagnostics.ProcessStartInfo(Environment.C urrentDirectory + @"\" +
pathEXE);
string args = "argument";
startInfo.WorkingDirectory = Environment.CurrentDirectory;
startInfo.Arguments = args;
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.CreateNoWindow = true;

normComm.StartInfo = startInfo;
try
{
normComm.Start(); //exception here

}

Any thoughts???Any help will be greatly appaerciated as i am unable to
get a breakthrough on this issue.

Perhaps current directory has changed. I believe that some of the dialog
boxes like open file change this and you can change it yourself as well.
Use Path.GetDirectoryName(Application.ExecutablePath) instead.

SP

Aug 23 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: thomas-lists | last post by:
Hey folks, before posting to the bugs-list I would like to try it here to get some help :). Every now and then MySQL-4.0.13 crashes on my Dual-Athlon-MP-machine. Its not reproducible nor I know...
9
by: Sudesh Sawant | last post by:
Hello, We have an application which communicates using remoting. There is a server which is a Windows Service. The server exposes an object which is a singleton. The client is a Web Application...
1
by: Primo | last post by:
Hello, I am building a data management application with the following processes: Process 1 is a Windows service which uses FileSystemWatcher to monitor a directory. Process 2 opens a file...
2
by: Praveen K | last post by:
I have a problem in communicating between the C# and the Excel Interop objects. The problem is something as described below. I use Microsoft Office-XP PIA dll’s as these dll’s were been...
7
by: WALDO | last post by:
I wrote a console application that basically consumes arguments and starts other command line apps via System.Process. Let's call it XCompile for now. I wrote a Visual basic add-in that does pretty...
1
by: Steven M. | last post by:
Greetings... I need desperate help with my problem. I guess the solution is related in some way with the cookies getting lost in the authentication process working with some web servers. ...
5
by: LRK | last post by:
Earlier this week we set up a second application pool to be able to implement trusted connections between ASP.NET apps and a SQL Server database on a different server. The trusted connection is...
5
by: Benzi Eilon | last post by:
I have written a C# application which should run as a Windows Service. I must avoid having multiple instances of the application on one machine so I inserted the following code at the beginning of...
11
by: garyusenet | last post by:
For this first time today I used the System.Diagnositcs namespace to launch a program from my c# code. The program launches OK but I have something which has completely stumped me. The...
9
by: HC | last post by:
Hello, all, I started out thinking my problems were elsewhere but as I have worked through this I have isolated my problem, currently, as a difference between MSDE and SQL Express 2005 (I'll just...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.