i'm having a problem in executing a batch file from my c++ code
i've included all the necesary headers like dos.h,process.h,stdlib.h

code:
system(c:\new\ram.bat);

there is no error in the program but the batch file does not get executed.....


please help ................

Recommended Answers

All 8 Replies

You need to escape the backslashes with another backslash (just like using a backslash to escape double quotes and the like): system("c:\\new\\ram.bat");

i've tried this but it dos'nt worked............

system(c:\\new\\ram.bat);
does'nt worked ...........

You need to send system() a string. Put c:\\new\\ram.bat in double-quotes.

system("c:\\new\\ram.bat");
it still doesnt worked..........
everything is working fine and there is no error in program .but the batch file doesnt executes..............

Then
1) the batch file is not in the directory specified
2) the system call is not being executed
3) the batch file is being executed and give no feedback
4) the program is not working fine

Maybe more details are necessary.

what is content of your batch file?

Here is a tutorial on system. Maybe this will help you debug the issue.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.