473,320 Members | 1,856 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,320 software developers and data experts.

Batch file processing with C#

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)?
Mar 28 '07 #1
3 1508
On Wed, 28 Mar 2007 16:22:01 -0700, Gaurav
<Ga****@discussions.microsoft.comwrote:
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.
Mar 28 '07 #2
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.

"Peter Duniho" wrote:
On Wed, 28 Mar 2007 16:22:01 -0700, Gaurav
<Ga****@discussions.microsoft.comwrote:
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.
Mar 29 '07 #3
On Wed, 28 Mar 2007 21:00:01 -0700, Gaurav
<Ga****@discussions.microsoft.comwrote:
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
Mar 29 '07 #4

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

Similar topics

3
by: DBA | last post by:
I have a windows batch file that executes a SQL Server bcp command. I would like to obtain a return code if the bcp command fails. However, I cannot seem to find the return code (if any) for bcp....
2
by: Paul Reddin | last post by:
Hi, (V8.1 Fp2) Our application uses JDBC batch to execute mutiple insert statements and we saw a strange thing this morning. There were 4 SQL Insert statements in the batch, and we know the...
6
by: Charles Neitzel | last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C# 2005 Express) that is nothing more than a simple UI with buttons on it. The buttons do various things like running...
2
by: | last post by:
Hi, I have just started using MSSQL and the DOS environment at work. I have a lot of experience with Sybase and the UNIX environment, but this is a whole new ball of wax. I'd like to use osql...
1
by: Crash | last post by:
Hi, ..NET v1.x SP1 VS 2003 SQL Server 2000 SP3 Server 2000, XP, Server 2003 I would like to programmatically execute {possibly many} SQL Server batch scripts. Aka I have many scripts that...
4
by: acantatore | last post by:
Hello! I'm looking for patterns, best practices, examples - reference material - that apply to Batch Processing, that is: Basic job control (start and stop) Job partitioning Parallel...
16
by: Richard Maher | last post by:
Hi, I have this Applet-hosted Socket connection to my server and in an ONevent/function I am retrieving all these lovely rows from the server and inserting them into the Select-List. (The on...
3
by: ludwig_stuyck | last post by:
Hi, does someone has some links to information about how I would approach and implement batch processing in C#? Thanks! Kind regards, Ludwig
6
by: Thomas Guettler | last post by:
Hi, I tried PIL for image batch processing. But somehow I don't like it - Font-Selection: You need to give the name of the font file. - Drawing on an image needs a different object that pasting...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.