Use cmd to execute .exe

5 ビュー (過去 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 Center および File ExchangeSearch Path についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by