How to get the path of exe file?
Mostrar comentarios más antiguos
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?
Respuesta aceptada
Más respuestas (4)
Image Analyst
el 21 de Dic. de 2016
3 votos
See my attached function.
3 comentarios
Image Analyst
el 21 de Dic. de 2016
See discussion of MCR_CACHE_ROOT.
Try setting your MCR_CACHE_ROOT environment variable to dot.
This will make it unpack the CTF to your app's folder on your deployed/target computer. Yes, it will clutter up that folder with stuff but now any files you deployed will most likely be found, whereas they might not be if you used the wrong code to get the folder where your actual executable lives. Remember the executable your users run is actually like a shell program that unpacks a bunch of stuff, including the actual executable, to some secret folder. And it is that executable that actually gets run. So there are two folders, or even more. The one given by pwd. The one given by mfilename('fullpath'). And the one given by ctfroot. And there are even more folders than that. Granted, it's a confusing mess.
Bogdan Dzyubak
el 21 de Jul. de 2018
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
el 21 de Jul. de 2018
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
el 22 de Dic. de 2016
Editada: Stefanie Schwarz
el 21 de Oct. de 2024
Stefanie Schwarz
el 21 de Oct. de 2024
0 votos
See also:
How can I find the directory containing my compiled application?
Categorías
Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!