필터 지우기
필터 지우기

Can I run a bat file with Matlab?

조회 수: 238 (최근 30일)
Jorge
Jorge 2011년 1월 27일
댓글: Waldemar Gessler 2019년 11월 12일
Hi! I have a bat file created to kill process:
taskkill /IM excel.exe
Can I run it with Matlab?
Thanks
  댓글 수: 3
Walter Roberson
Walter Roberson 2017년 9월 22일
system('nameOfBatFile.bat')
Waldemar Gessler
Waldemar Gessler 2019년 11월 12일
or without bat file:
system('taskkill /IM excel.exe')

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2011년 1월 27일
You can use system() or dos() or ! (exclamation-mark) to run a bat file.

추가 답변 (5개)

Vieniava
Vieniava 2011년 1월 27일
use this command:
system
Matlab's documentation for this function is available after
>> doc system
or on the WEB

Jorge
Jorge 2011년 1월 27일
I got the result I wanted. Thank you very much to both

Koteswar Rao  Jerripothula
Koteswar Rao Jerripothula 2014년 1월 31일
thank from me too

Victor Villar
Victor Villar 2014년 7월 3일
Very useful.
Thanks!

Babak babak
Babak babak 2017년 7월 24일
Hi, guys when I use system or status for my batch file, it does not make outputs like when I double click on my batch file!
>> system('D:\CODE\workshop\MCNP\bab.bat','-echo')
C:\WINDOWS\system32>mcnp i=kc.i
ans =
-1.0737e+09
when I double clike on my batch file, it makes for me 3 outputs.
  댓글 수: 5
Babak babak
Babak babak 2017년 7월 24일
thank you again. I really try to solve it but unfortunately, I couldn't. I have copies 0f Mcnp, bab.bat and kc.i files in Matlab root, D:\CODE\workshop\MCNP\bab.bat and in C:\WINDOWS\system32 but it does not work. My batch file:
mcnp i=kc.i
and I use this code for my batch file too
mcnp i=kc.i
"C:\WINDOWS\system32\mcnp" i=kc.i
the answer:
>> [status, result] = system('C:\Windows\System32\bab.bat')
status =
0
result =
'
C:\WINDOWS\system32>mcnp i=kc.i
mcnp ver=2.6.0 ld=Wed Apr 09 08:00:00 MST 2008 07/25/17 01:36:59
bad trouble in mcnp in routine exemes
input file kc.i does not exist.
why Matlab try to run it in "WINDOWS\system32"?
Walter Roberson
Walter Roberson 2017년 7월 24일
Your bat file has a cd in it

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by