Batch file processing with C#

G

Guest

Hi,

I have a requirement to execute a .bat file from c#. I am aware of the
process to do so using System.Diagnostics namespace. However, I need to
replace the values in my .bat file at runtime when it is called by C#.

eg. In my .bat file
"C:\test.bat" -xml "C:\07.xml" -xsl "C:\fo.xsl" "c:\output.pdf"

I would like to replace the hardcoded values for "C:\test.bat", "C:\07.xml",
"C:\fo.xsl" when calling from C#.

Can somebody plz let me how can i implement this (guess by %1 etc in .bat)?
 
P

Peter Duniho

Can somebody plz let me how can i implement this (guess by %1 etc in
.bat)?

Yes. You do it exactly as you'd do it with the command line, and then
include the appropriate parameters when executing the batch file just as
you would using the command line.
 
G

Guest

Thanks Peter.
I have not really worked with batch files before. Could you please point me
to some code on how to do this with command line etc.?

Thanks.
 
P

Peter Duniho

Thanks Peter.
I have not really worked with batch files before. Could you please point
me to some code on how to do this with command line etc.?

Are you asking how to write a batch file? I can't say this is exactly the
right place for you to learn that. That said...

For starters, see: http://en.wikipedia.org/wiki/Batch_file
There are a number of external references at the end of that article, at
least some of which should help.

Basically, the syntax you already described ("%1") is used to reference
parameters included in the command line. The numeral indicates which
parameter is being referenced, with 1 being the 1st parameter.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top