MATLAB Answers

Strange Environment Behavior Windows 10 and MATLAB

4 views (last 30 days)
dpb
dpb on 27 Aug 2021
Edited: dpb on 29 Aug 2021
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 Comments
dpb
dpb on 29 Aug 2021
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...

Sign in to comment.

Answers (0)

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!