Sandeep Bhat
Sandeep Bhat

Reputation: 335

how to run a cmd file from matlab

I am trying to run a cmd file from MATLAB but unable to execute it. Can anybody see nay problem in the below code?

this is what I have inside my cmd file:

echo on
>test.log 2>&1 (
C:/testProj/Make/makeit.cmd param1
)

And this is the MATLAB code:

Out = 'C:/testProj/test.cmd';
system(Out);

But this actually does not run the cmd file.

Upvotes: 0

Views: 350

Answers (3)

Sandeep Bhat
Sandeep Bhat

Reputation: 335

Well for somereason it would not run if i would give the complete path of the cmd in bat file. so I had a cd command to change the directory and then run. now it runs fine, Thanks all appreciate your help!

Upvotes: 1

Highman
Highman

Reputation: 145

You can just type the following strings to get things down:

!(c:/testProj/test.cmd)

This is actually no different from

system('c:/testProj/test.cmd')

I think you should check if the path is wrong. As to your code in the cmd file, that's beyond my ability to help.

Upvotes: 0

Scott
Scott

Reputation: 99

What about using eval, like this:

eval(['!test.cmd']);

I have succesfully used this to run .bat files (and this output of the .bat script showed in my matlab command line). I also found this dos command, but I am not sure if it works allright:

Upvotes: 0

Related Questions