フィルターのクリア

Check the status of .exe file without running it

5 ビュー (過去 30 日間)
Hülya Sukas
Hülya Sukas 2020 年 1 月 1 日
コメント済み: Hülya Sukas 2020 年 1 月 1 日
Hello everyone
I am trying to check an .exe file exists or not.
[status,cmdout] = system('tec360.exe')
This command works for it. But my main purpose is that, code should check ONLY the status, it should not run it.
If .exe file is exists it will open a .dat file in the tec360.exe, if it is not exists it will show an error box.
This code works for it, but it open tec360.exe two times because of [status,cmdout] = system('tec360.exe') this command.
In first opening it opens an empty tec360.exe file, when I close it, it opens tec360.exe file with "threeDOF_result_trajectory_turning.dat" file.
Is there any one to help me about this issue?
Thanks in advance!
[status,cmdout] = system('tec360.exe')
if status==0
!tec360.exe .\threeDOF_result_trajectory_turning.dat
elseif status==1
errordlg('tec360.exe could not found.')
end

採用された回答

Walter Roberson
Walter Roberson 2020 年 1 月 1 日
exename = 'tec360.exe';
pathparts = regexp(getenv('PATH'), ';', 'split');
found = false;
for K = 1 : length(pathparts)
if exist(fullfile(pathparts{K}, exename), 'file')
found = true;
break;
end
end
if ~found
error('I cannot find the executable "%s"', exename);
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSoftware Development Tools についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by