Repost: batch files and c#

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
Gaurav,

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

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

Hope this helps.
 
Works like a charm!
Thanks a bunch for your help...

Nicholas Paldino said:
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]
- (e-mail address removed)

Gaurav said:
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?
 
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
 

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

Back
Top