Borrar filtros
Borrar filtros

Matlab inherited environment when launched from command window

55 visualizaciones (últimos 30 días)
Richard
Richard el 30 de Jul. de 2024 a las 23:36
Comentada: Image Analyst el 31 de Jul. de 2024 a las 15:47
It has been my experience that Matlab inherits the dos environment when launched from a command window (or powershell).
e.g. open Command Prompt
c:\Users\Foo> matlab
This does in fact work on 2 laptops Win10 and Win11. On a 3rd Win11 laptop however it does not seem to work. I did some workarounds within Matlab to get past that but I also found when I execute dos .bat from Matlab on that 3rd laptop, The dos window opened does not have the env from the original that I used to launch Matlab.
Is there a workaround? My searches came up dry.

Respuesta aceptada

Image Analyst
Image Analyst el 31 de Jul. de 2024 a las 15:11
What information from the DOS environment do you need?
Have you tried getenv?
I guess you're doing, from the command window in MATLAB:
>>!dos.bat
to execute dos.bat via a system call. Or are you doing
>>run('dos.bat')
or
>>system('dos.bat')
or
>> winopen('dos.bat')
What ODS commands are in the batch file you're trying to run? Can you attach it with the paperclip icon (you might have to zip it up)?
  2 comentarios
Richard
Richard el 31 de Jul. de 2024 a las 15:23
I found a workaround by using setenv and getenv within Matlab. Some of the commands were python and I was trying to avoid using pyenv. I ended up using pyenv as well to setup python. Once you call penv(...) it remembers that setup forever which has the potential to crowbar other users on shared computers.
Image Analyst
Image Analyst el 31 de Jul. de 2024 a las 15:47
I'm glad getenv and setenv worked for you. 🙂
If this Answer solves your original question, then could you please click the "Accept this answer" link to award the answerer with "reputation points" for their efforts in helping you? They'd appreciate it. Thanks in advance. 🙂 Note: you can only accept one answer (so pick the best one) but you can click the "Vote" icon for as many Answers as you want. Voting for an answer will also award reputation points.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by