Strange Environment Behavior Windows 10 and MATLAB
4 views (last 30 days)
Show older comments
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
Answers (0)
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!