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

I want to query the current username on the Windows platform from within MATLAB.

 Accepted Answer

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

Products

Release

R14SP2

Community Treasure Hunt

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

Start Hunting!