How to get the path of exe file?

37 ビュー (過去 30 日間)
edit
edit 2016 年 12 月 21 日
回答済み: Stefanie Schwarz 2024 年 10 月 21 日
I have convert my .m file(a function) to .exe file, and i run the .exe file from cmd like this:
Now i want to get the path of exe file automatic(in this example it is D:\test\),how can i get it?

採用された回答

Walter Roberson
Walter Roberson 2016 年 12 月 21 日
  6 件のコメント
Walter Roberson
Walter Roberson 2020 年 5 月 12 日
I don't know at the moment, but you are welcome to count them yourself.
Walter Roberson
Walter Roberson 2020 年 5 月 15 日
E Swan: the number that are "now useless because they only contain a dead link" is low. When you click on a view_thread link, the page that you are taken to now includes a link to the relevant Google Groups discussion.

サインインしてコメントする。

その他の回答 (4 件)

Image Analyst
Image Analyst 2016 年 12 月 21 日
See my attached function.
  3 件のコメント
Bogdan Dzyubak
Bogdan Dzyubak 2018 年 7 月 21 日
Where should the MCR_CACHE_ROOT be set? Would I have setenv(MCR_CACHE_ROOT,'.') as part of the compiled code, or is there a different method?
Image Analyst
Image Analyst 2018 年 7 月 21 日
That should be fine. If you don't set it, it picks some hidden place, like maybe something under c:\users somewhere. If you do that then you need to make sure you use the -a option to include any files you need to load at runtime. If you use dot, then you can put them as subfolders of your installation folder and put them there with a third party installer (like I do).

サインインしてコメントする。


edit
edit 2016 年 12 月 22 日
編集済み: Stefanie Schwarz 2024 年 10 月 21 日
Thank you for your help. I have solve the problem by add the showpath.m into my function .m file then convert it to .exe. The detail of showpath.m file is like this:
function [thePath]=showpath()
% Show EXE path:
if isdeployed % Stand-alone mode.
[status, result] = system('set PATH');
thePath = char(regexpi(result, 'Path=(.*?);', 'tokens', 'once'));
else % Running from MATLAB.
thePath=pwd;
end
return

José-Luis
José-Luis 2016 年 12 月 21 日
  2 件のコメント
edit
edit 2016 年 12 月 21 日
It seem no work,and i think what i want to do just something like mfilename(it seem just work in .m file not in .exe file).
José-Luis
José-Luis 2016 年 12 月 21 日
"It seem no work" doesn't really help us understand what the problem is. Could you show what is the result you expect and what you use as input?

サインインしてコメントする。


Stefanie Schwarz
Stefanie Schwarz 2024 年 10 月 21 日

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by