How do I query the current username on a Windows platform from within MATLAB?

84 views (last 30 days)

Accepted Answer

MathWorks Support Team
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%');

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Products


Release

R14SP2

Community Treasure Hunt

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

Start Hunting!