How do I query the current username on a Windows platform from within MATLAB?
49 views (last 30 days)
Show older comments
I want to query the current username on the Windows platform from within MATLAB.
Accepted Answer
MathWorks Support Team
on 8 Dec 2010
The name of the current user is specified by the Windows %USERNAME% system variable. The contents of the %USERNAME% system variable may be queried from within MATLAB by using the GETENV or DOS functions:
username=getenv('USERNAME')
or
[s,username]=dos('echo %USERNAME%');
0 Comments
More Answers (0)
See Also
Categories
Find more on Language Fundamentals 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!