Reply
Old March 27th, 2008 Top | #1
 
Complete's Avatar
OSNN Addict
Joined: August 2005
Posts: 94
Reputation: 10
Power: 79

Default running a batch file from a command window launched from a c sharp program

I have been able to launch a batch file from a C# program in a number of ways.

Duncan Mackenzie's blog on msdn shows a number of ways how it can be done and I have tried them. (http://blogs.msdn.com/csharpfaq/arch...01/146375.aspx).

But I have a unique problem. The batch file launches a program that seems to require that a command window (cmd) be open when it runs. Because of this, the batch file works if I launch it from a command line, but when I launch it in a C# program, an exception is thrown.

So my question is this. How can I open a cmd window from C# and feed it the command to run the batch routine?
Complete is offline   Reply With Quote
Old March 28th, 2008 Top | #2
 
LordOfLA's Avatar
Godlike!
Joined: February 2004
Location: Salisbury, Wiltshire, UK
Posts: 7,015
Blog Entries: 5
Reputation: 4137
Power: 209

Default Re: running a batch file from a command window launched from a c sharp program

why not just launch "cmd <path to batch file>" instead of "<path to batch file>\<batchfile>"?



If HK-47 and GLaDOS had a child, the character they create would cause the video game world to overdose on awesome. -sheridanmovieguy: Dragon age forum user.
LordOfLA is offline   Reply With Quote

Reply

Bookmarks

Thread Tools

Posting Rules

Similar Threads
Thread Thread Starter Forum Replies Last Post
vbscript or batch file to play audio file for user on startup Punkrulz Web Design & Coding 10 November 29th, 2006 2:48pm
Excel minimizes when a linked file launched Terrahertz Windows Desktop Systems 4 February 28th, 2006 11:09pm
Delay a Batch command the_tazinator Web Design & Coding 5 February 21st, 2004 4:06pm
running program/batch/link on shutdown Shotokhaan Windows Desktop Systems 2 August 29th, 2002 1:25pm
Running *.reg files from a batch file a1ehouse Windows Desktop Systems 3 August 4th, 2002 6:51pm