Check the status of .exe file without running it
8 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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 Exchange 中查找有关 Pulsed Waveforms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!