473,405 Members | 2,421 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.

Repost: batch files and c#

I have a simple .bat file (TESTMAIN.bat):
"C:\fo.bat" -xml "C:\07.xml" -xsl "C:\fo.xsl" "c:\output.pdf"

I call this using C#:
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName =@"c:\TESTMAIN.bat";

But I want to remove the hardcoded parameters ("C:\07.xml" and "C:\fo.xsl")
from TESTMAIN.bat file.

So i modify the .bat file as (is it correct??):
"C:\fo.bat" -xml %1 -xsl %2 "c:\output.pdf"

Now how do i call/replace these parameters in C#
p.StartInfo.Arguments= ??

Any pointers on how to do this?
Mar 29 '07 #1
3 1276
Gaurav,

I believe that you want to set the Arguments property to:

"\"C:\\07.xml\" \"C:\\fo.xsl\""

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Gaurav" <Ga****@discussions.microsoft.comwrote in message
news:A4**********************************@microsof t.com...
>I have a simple .bat file (TESTMAIN.bat):
"C:\fo.bat" -xml "C:\07.xml" -xsl "C:\fo.xsl" "c:\output.pdf"

I call this using C#:
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName =@"c:\TESTMAIN.bat";

But I want to remove the hardcoded parameters ("C:\07.xml" and
"C:\fo.xsl")
from TESTMAIN.bat file.

So i modify the .bat file as (is it correct??):
"C:\fo.bat" -xml %1 -xsl %2 "c:\output.pdf"

Now how do i call/replace these parameters in C#
p.StartInfo.Arguments= ??

Any pointers on how to do this?

Mar 29 '07 #2
Works like a charm!
Thanks a bunch for your help...

"Nicholas Paldino [.NET/C# MVP]" wrote:
Gaurav,

I believe that you want to set the Arguments property to:

"\"C:\\07.xml\" \"C:\\fo.xsl\""

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Gaurav" <Ga****@discussions.microsoft.comwrote in message
news:A4**********************************@microsof t.com...
I have a simple .bat file (TESTMAIN.bat):
"C:\fo.bat" -xml "C:\07.xml" -xsl "C:\fo.xsl" "c:\output.pdf"

I call this using C#:
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName =@"c:\TESTMAIN.bat";

But I want to remove the hardcoded parameters ("C:\07.xml" and
"C:\fo.xsl")
from TESTMAIN.bat file.

So i modify the .bat file as (is it correct??):
"C:\fo.bat" -xml %1 -xsl %2 "c:\output.pdf"

Now how do i call/replace these parameters in C#
p.StartInfo.Arguments= ??

Any pointers on how to do this?


Mar 29 '07 #3
Hi,
Does this solve your problem:

p.StartInfo.Arguments = String.Format( " -xml {0} -xls {1} {2}" , new
object[] { @"C:\07.xml" , @"C:\fo.xsl", @"c:\output.pdf"} )

I think it does

"Gaurav" <Ga****@discussions.microsoft.comwrote in message
news:A4**********************************@microsof t.com...
>I have a simple .bat file (TESTMAIN.bat):
"C:\fo.bat" -xml "C:\07.xml" -xsl "C:\fo.xsl" "c:\output.pdf"

I call this using C#:
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName =@"c:\TESTMAIN.bat";

But I want to remove the hardcoded parameters ("C:\07.xml" and
"C:\fo.xsl")
from TESTMAIN.bat file.

So i modify the .bat file as (is it correct??):
"C:\fo.bat" -xml %1 -xsl %2 "c:\output.pdf"

Now how do i call/replace these parameters in C#
p.StartInfo.Arguments= ??

Any pointers on how to do this?

Mar 29 '07 #4

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

Similar topics

12
by: Moosebumps | last post by:
So, after reading some messages about os.system, and looking at the popen stuff and trying it a bit, I still have not found a way to keep a command window open for several commands (on Windows...
1
by: Bernhard Sollfrank | last post by:
Hello, i have to start a batch process from a dll to transfer files created by this dll to remote ftp server. I created a batch file: ftp -n -v -i -s:D:\batch\ftpcmds.txt ftp-server and a...
2
by: Herb Stevenson | last post by:
Hello all. I need to set up a batch file to work w/ the Visual Studio.NET 2003 command prompt. However, when I run the batch file it uses the standard command prompt. Is there a way to...
7
by: erniedude | last post by:
Hi, I'm a newbie and I was wondering if anyone knew a (Python) script to run 4 batch files, one after the other (assuming the directories are known). It would be better if all 4 batch files...
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...
0
by: Steve Jorgensen | last post by:
I remember that I used to set up utility batch files, and create Windows shortcuts to them that would ask the user for parameters to supply to the batch files. From what I can tell, this...
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...
1
by: Charles | 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...
14
by: Steve McLellan | last post by:
Hi, Sorry to repost, but this is becoming aggravating, and causing me a lot of wasted time. I've got a reasonably large mixed C++ project, and after a number of builds (but not a constant...
4
by: | last post by:
Hello, I am attempting to convert multiple .wav files to the .flac format via a batch script. I know that this can be done with numerous software implementations automatically for me; however, i am...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.