Click here to Skip to main content
16,022,309 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
hello
I have a batch(.bat) file. When I double click on it, it work correct but when I execute it by code Process.Start() it does not work correct and I want to execute it by code.

Thank
Posted
Updated 3-Mar-11 11:44am
v2
Comments
Dave Kreskowiak 3-Mar-11 17:28pm    
Without seeing the code you used to launch the batch file, it's impossible to tell you what you did wrong. Also, where is the batch file located? Is it in the same folder as the .EXE that's trying to launch it?
thatraja 3-Mar-11 20:24pm    
I second Dave

1 solution

Running a batch file from a program is a strange idea and pretty much useless: there are many other way to integrate software or make codes pluggable.

So, I never tried it. But few seconds ago I tried, out of curiosity:

C#
System.Diagnostics.Process.Start("mybatch.bat");


Note, I didn't even run "CMD.EXE" with the batch file as a parameter, I tried to start batch file itself (I thought this could be a problem). It worked immediately. Needless to say, I had my executable and the batch file in same directory (see Dave's comment). Did you?

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900