Check the status of .exe file without running it
8 views (last 30 days)
Show older comments
Hülya Sukas
on 1 Jan 2020
Commented: Hülya Sukas
on 1 Jan 2020
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 Comments
Accepted Answer
Walter Roberson
on 1 Jan 2020
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
More Answers (0)
See Also
Categories
Find more on Pulsed Waveforms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!