Strange Environment Behavior Windows 10 and MATLAB

조회 수: 5 (최근 30일)
dpb
dpb 2021년 8월 27일
편집: dpb 2021년 8월 29일
I had been using
if strcmpi(getenv('userdomain'),'SPECIFIC_STRING')
to identify which system was running on in a compiled app and all seemed fine.
The college machine was/is Win10 while personal was still Win7 -- just got new box for home as had hardware failure on older; this one is also Win10 Pro, but now the above returns an empty string.
The truly puzzling part is from MATLAB if I execute
>> !set
ALLUSERSPROFILE=C:\ProgramData
...
PUBLIC=C:\Users\Public
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\Duane\AppData\Local\Temp
TMP=C:\Users\Duane\AppData\Local\Temp
USERDOMAIN_ROAMINGPROFILE=DESKTOP-4R8AJAE
USERPROFILE=C:\Users\Duane
windir=C:\Windows
>>
and, indeed, USERDOMAIN is apparently not set in the environment.
But, if I open CMD.EXE and type SET there, then the result is
Microsoft Windows [Version 10.0.19042.685]
(c) 2020 Microsoft Corporation. All rights reserved.
C:\Users\Duane>set
ALLUSERSPROFILE=C:\ProgramData
...
PUBLIC=C:\Users\Public
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\Duane\AppData\Local\Temp
TMP=C:\Users\Duane\AppData\Local\Temp
USERDOMAIN=DESKTOP-4R8AJAE
USERDOMAIN_ROAMINGPROFILE=DESKTOP-4R8AJAE
USERNAME=Duane
USERPROFILE=C:\Users\Duane
windir=C:\Windows
C:\Users\Duane>
then USERDOMAIN does, in fact, exst.
Can anybody explain why the behavior that while running inside MATLAB can't see the USERDOMAIN environment variable or better yet, how to have it be visible?
  댓글 수: 3
Walter Roberson
Walter Roberson 2021년 8월 29일
Right, experiment with
system('echo %userdomain%')
dpb
dpb 2021년 8월 29일
편집: dpb 2021년 8월 29일
Thanks, guys.
I have no explanation; I had restarted Matlab quite a number of times since the install; this was the first time after had gotten files back for the compiled application and tried to update it for the new machine and ran into the problem.
Either "!" or Walter's system call returned same bizarre result -- I finally rebooted the entire system and the symptoms have now disappeared, at least temporarily.
Just yet another bizarre Windows anomaly, it seems...

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by