필터 지우기
필터 지우기

Use cmd to execute .exe

조회 수: 2 (최근 30일)
han han
han han 2019년 12월 9일
답변: VBBV 2023년 6월 25일
As the title, I don't want to execute cmd in a specified or specific directory, but it can be executed no matter which directory I execute the file in.
How can it be modified?
out = fileread('1.txt');
cmd = ['xxx.exe', out];
system(cmd)
THX

답변 (1개)

VBBV
VBBV 2023년 6월 25일
Use a fullfile function to read the files from whichever directory and /or drive they are located as shown below.
out = fileread([fullfile('c:\','myfiles'),filesep,'1.txt']);
cmd = ['xxx.exe', out];
system(cmd)
Check if your are working in MS Windows or Mac OS environment, and modify the filesep to read the files from the source locations

카테고리

Help CenterFile Exchange에서 Search Path에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by