Effacer les filtres
Effacer les filtres

Check the status of .exe file without running it

8 vues (au cours des 30 derniers jours)
Hülya Sukas
Hülya Sukas le 1 Jan 2020
Commenté : Hülya Sukas le 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

Réponse acceptée

Walter Roberson
Walter Roberson le 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

Plus de réponses (0)

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by