By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,594 Members | 3,680 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,594 IT Pros & Developers. It's quick & easy.

Unable to run .exe application using C# code

P: n/a
Hi,

I have an exe that i need to call from my C# Program with two
arguments(filenames)

for example
Suppose if i have an application "test.exe" , whose functionality is to
convert a '.doc' file to '.txt' file
On cmd i would normally give the following command as:

test.exe abc.doc xyz.txt

and it works fine and performs its job of conversion.

but what if i want to execute the same thing using my c# code.
i am using the following sample code:

Process compiler = new Process();
compiler.StartInfo.FileName = "test.exe" ;
compiler.StartInfo.Arguments = "abc.doc xyz.txt" ;
compiler.StartInfo.UseShellExecute = false;
compiler.StartInfo.RedirectStandardOutput = true;
compiler.Start();

when i try to invoke the test.exe using the above code , it fails to
perform its operation of conversion.

how is setworking directory to be used?
how should we specify the path for all the files.?
how should we give the path for the above files to be used?

Can anyone tell me if i need to add anything more to the above code

It would be great if somebody could provide some help on the above
topic.

Jan 11 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Did you put test.exe and you program together?
If not, you should give the full name of test.exe .
Such as:
Process.Start("c:\\test.exe","abc.doc xyz.txt");
<kb******@gmail.com>
??????:11**********************@p59g2000hsd.google groups.com...
Hi,

I have an exe that i need to call from my C# Program with two
arguments(filenames)

for example
Suppose if i have an application "test.exe" , whose functionality is to
convert a '.doc' file to '.txt' file
On cmd i would normally give the following command as:

test.exe abc.doc xyz.txt

and it works fine and performs its job of conversion.

but what if i want to execute the same thing using my c# code.
i am using the following sample code:

Process compiler = new Process();
compiler.StartInfo.FileName = "test.exe" ;
compiler.StartInfo.Arguments = "abc.doc xyz.txt" ;
compiler.StartInfo.UseShellExecute = false;
compiler.StartInfo.RedirectStandardOutput = true;
compiler.Start();

when i try to invoke the test.exe using the above code , it fails to
perform its operation of conversion.

how is setworking directory to be used?
how should we specify the path for all the files.?
how should we give the path for the above files to be used?

Can anyone tell me if i need to add anything more to the above code

It would be great if somebody could provide some help on the above
topic.

Jan 11 '07 #2

P: n/a


Thanks for the suggestion !
Actually i have tried this , but still does'nt seem to work
if u have some other suggestion , plz do post again.

bhavesh

<lijg...@gmail.comwrote:
Did you put test.exe and you program together?
If not, you should give the full name of test.exe .
Such as:
Process.Start("c:\\test.exe","abc.doc xyz.txt");
<kb******@gmail.com>
??????:11**********************@p59g2000hsd.google groups.com...
Hi,

I have an exe that i need to call from my C# Program with two
arguments(filenames)

for example
Suppose if i have an application "test.exe" , whose functionality is to
convert a '.doc' file to '.txt' file
On cmd i would normally give the following command as:

test.exe abc.doc xyz.txt

and it works fine and performs its job of conversion.

but what if i want to execute the same thing using my c# code.
i am using the following sample code:

Process compiler = new Process();
compiler.StartInfo.FileName = "test.exe" ;
compiler.StartInfo.Arguments = "abc.doc xyz.txt" ;
compiler.StartInfo.UseShellExecute = false;
compiler.StartInfo.RedirectStandardOutput = true;
compiler.Start();

when i try to invoke the test.exe using the above code , it fails to
perform its operation of conversion.

how is setworking directory to be used?
how should we specify the path for all the files.?
how should we give the path for the above files to be used?

Can anyone tell me if i need to add anything more to the above code

It would be great if somebody could provide some help on the above
topic.
Jan 11 '07 #3

P: n/a
Try like this:
Process.Start("c:\\test.exe","c:\\abc.doc c:\\xyz.txt");

<kb******@gmail.com>
??????:11**********************@i39g2000hsf.google groups.com...
>

Thanks for the suggestion !
Actually i have tried this , but still does'nt seem to work
if u have some other suggestion , plz do post again.

bhavesh

<lijg...@gmail.comwrote:
>Did you put test.exe and you program together?
If not, you should give the full name of test.exe .
Such as:
Process.Start("c:\\test.exe","abc.doc xyz.txt");
<kb******@gmail.com>
??????:11**********************@p59g2000hsd.googl egroups.com...
Hi,

I have an exe that i need to call from my C# Program with two
arguments(filenames)

for example
Suppose if i have an application "test.exe" , whose functionality is to
convert a '.doc' file to '.txt' file
On cmd i would normally give the following command as:

test.exe abc.doc xyz.txt

and it works fine and performs its job of conversion.

but what if i want to execute the same thing using my c# code.
i am using the following sample code:

Process compiler = new Process();
compiler.StartInfo.FileName = "test.exe" ;
compiler.StartInfo.Arguments = "abc.doc xyz.txt" ;
compiler.StartInfo.UseShellExecute = false;
compiler.StartInfo.RedirectStandardOutput = true;
compiler.Start();

when i try to invoke the test.exe using the above code , it fails to
perform its operation of conversion.

how is setworking directory to be used?
how should we specify the path for all the files.?
how should we give the path for the above files to be used?

Can anyone tell me if i need to add anything more to the above code

It would be great if somebody could provide some help on the above
topic.

Jan 11 '07 #4

P: n/a
Is it required to have all the files in the same directory?
For example:
Process.Start("C:\\My Folder\\test.exe", "D:\\abc.doc C:\\test
folder\\xyz.txt");

Will it work?

Thanks,
BK
<lijg...@gmail.comwrote:
Try like this:
Process.Start("c:\\test.exe","c:\\abc.doc c:\\xyz.txt");

<kb******@gmail.com>
??????:11**********************@i39g2000hsf.google groups.com...


Thanks for the suggestion !
Actually i have tried this , but still does'nt seem to work
if u have some other suggestion , plz do post again.

bhavesh

<lijg...@gmail.comwrote:
Did you put test.exe and you program together?
If not, you should give the full name of test.exe .
Such as:
Process.Start("c:\\test.exe","abc.doc xyz.txt");
<kb******@gmail.com>
??????:11**********************@p59g2000hsd.google groups.com...
Hi,

I have an exe that i need to call from my C# Program with two
arguments(filenames)

for example
Suppose if i have an application "test.exe" , whose functionality is to
convert a '.doc' file to '.txt' file
On cmd i would normally give the following command as:

test.exe abc.doc xyz.txt

and it works fine and performs its job of conversion.

but what if i want to execute the same thing using my c# code.
i am using the following sample code:

Process compiler = new Process();
compiler.StartInfo.FileName = "test.exe" ;
compiler.StartInfo.Arguments = "abc.doc xyz.txt" ;
compiler.StartInfo.UseShellExecute = false;
compiler.StartInfo.RedirectStandardOutput = true;
compiler.Start();

when i try to invoke the test.exe using the above code , it fails to
perform its operation of conversion.

how is setworking directory to be used?
how should we specify the path for all the files.?
how should we give the path for the above files to be used?

Can anyone tell me if i need to add anything more to the above code

It would be great if somebody could provide some help on the above
topic.
Jan 12 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.