422,538 Members | 2,033 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,538 IT Pros & Developers. It's quick & easy.

Problem with Process

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.