Strange Environment Behavior Windows 10 and MATLAB

3 次查看(过去 30 天)
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 个评论
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