473,405 Members | 2,167 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,405 software developers and data experts.

running from command prompt

Hi,
I am writing a program, and need to execute a part of it in command
prompt.

When I execute it in command prompt, I type the following
c:\> id3tag.exe music.wma show
and it returns for me an XML file.

How can I do that in C#. I was trying to do that by using the Process
object but got lost.
Thanks in Advance
Nov 16 '05 #1
3 3482
Xarky <be*********@yahoo.com> wrote:
I am writing a program, and need to execute a part of it in command
prompt.

When I execute it in command prompt, I type the following
c:\> id3tag.exe music.wma show
and it returns for me an XML file.

How can I do that in C#. I was trying to do that by using the Process
object but got lost.


Well, how far have you got? You definitely need to use Process, and
possibly ProcessStartInfo.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
Hi,
I was trying the following

Process wmaProcess = new Process();
string filePath, musicPath, xmlFile;

// contains the path for the program to be executed
filePath = Application.StartupPath+@"\id3tag.exe";
// contains the path for the music file
musicPath = this.musicPath + "\\" + this.musicName;
wmaProcess.StartInfo.FileName = filePath;
wmaProcess.StartInfo.Arguments = musicPath+" show";
wmaProcess.StartInfo.CreateNoWindow = true;
wmaProcess.StartInfo.UseShellExecute = false;
wmaProcess.Start();
wmaProcess.WaitForExit();
xmlFile = wmaProcess.StandardOutput.ReadToEnd();

My program is failing on the last line. It is giving me the following
error -

An unhandled exception of type 'System.InvalidOperationException'
occurred in system.dll

Additional information: StandardError has not been redirected.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #3
xarky <nospam@in_the_sea.kills.xarky> wrote:
I was trying the following

Process wmaProcess = new Process();
string filePath, musicPath, xmlFile;

// contains the path for the program to be executed
filePath = Application.StartupPath+@"\id3tag.exe";
// contains the path for the music file
musicPath = this.musicPath + "\\" + this.musicName;
wmaProcess.StartInfo.FileName = filePath;
wmaProcess.StartInfo.Arguments = musicPath+" show";
wmaProcess.StartInfo.CreateNoWindow = true;
wmaProcess.StartInfo.UseShellExecute = false;
wmaProcess.Start();
wmaProcess.WaitForExit();
xmlFile = wmaProcess.StandardOutput.ReadToEnd();

My program is failing on the last line. It is giving me the following
error -

An unhandled exception of type 'System.InvalidOperationException'
occurred in system.dll

Additional information: StandardError has not been redirected.


Are you sure it's not saying that StandardOutput has not been
redirected? Either way, if you're going to try to read from
StandardOutput, then:

a) You should be reading from it *before* your call to WaitForExit,
otherwise the buffer might end up being blocked

b) You must tell the StartInfo to redirect standard output.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4

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

Similar topics

2
by: Eric Ching | last post by:
Can I run pythonw with a script that takes command line arguments then launches a GUI? I try pythonw myscript.pyw -option arg (etc.) and nothing happens. Nothing, as in I am immediately returned...
7
by: MLH | last post by:
I have an sql script file that is supposed to create a set of database tables for me. Supposedly I type the following on my linux box and its all supposed to work... mysql (ENTER) \....
4
by: MLH | last post by:
I am having failures processing the following command and I wonder if you can tell me what I must do in order to have success. When I try to run source mysql_dump.sql.txt ==> it is a problem...
4
by: glenn | last post by:
I keep reading all sorts of books on VS that keep telling me to click on Tools/Visual Studio Command prompt to run this program or that program. However, I do not have such a menu choice. Where is...
3
by: Lionel | last post by:
I've recently installed VS.Net 2003 on a desktop running Windows XP. When I try to create a new ASP.Net Web Application I get an error message. 'Visual Studio.Net has detected that the...
5
by: vj | last post by:
Hi all, I am using C++Builder-5. I want to run multiple cpp files at the same time. If I use the C++Builder for running a cpp file (i.e., I just double click the cpp file, it then opens in the...
1
by: TPhung | last post by:
Hi, I have a simple question about running python on windows xp command prompt. The file is as follows and is named spam.py: print 2**8 print 'the bright side' + 'of life' print "hello...
51
by: Ojas | last post by:
Hi!, I just out of curiosity want to know how top detect the client side application under which the script is getting run. I mean to ask the how to know whether the script is running under...
6
by: mjahabarsadiq | last post by:
Hi, I have written a java code to execute ant targets via Servlet. I have given the code below. import org.apache.tools.ant.*; import org.apache.catalina.ant.*; . . . .
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.