The answer depends on which «command-line script» language you are in.
Cmd
In the old cmd.exe
command prompt or in a .bat
or .cmd
script, you can use the following:
%USERNAME%
— Gets just the username.
%USERDOMAIN%
— Gets the user’s domain.
PowerShell
In the PowerShell command prompt or a .ps1
or .psm1
script, you can use the following:
[System.Security.Principal.WindowsIdentity]::GetCurrent().Name
— Gives you the fully qualified username (e.g. Domain\Username). This is also the most secure method because it cannot be overridden by the user like the other $Env
variables below.
$Env:Username
— Gets just the username.
$Env:UserDomain
— Gets the user’s domain.
$Env:ComputerName
— Gets the name of the computer.
Any Shell
whoami
— Gets the user’s domain and username in the format «domain\username».
This also works on Unix systems as well, not just Windows, so it’s a nice cross-platform solution.
The answer depends on which «command-line script» language you are in.
Cmd
In the old cmd.exe
command prompt or in a .bat
or .cmd
script, you can use the following:
%USERNAME%
— Gets just the username.
%USERDOMAIN%
— Gets the user’s domain.
PowerShell
In the PowerShell command prompt or a .ps1
or .psm1
script, you can use the following:
[System.Security.Principal.WindowsIdentity]::GetCurrent().Name
— Gives you the fully qualified username (e.g. Domain\Username). This is also the most secure method because it cannot be overridden by the user like the other $Env
variables below.
$Env:Username
— Gets just the username.
$Env:UserDomain
— Gets the user’s domain.
$Env:ComputerName
— Gets the name of the computer.
Any Shell
whoami
— Gets the user’s domain and username in the format «domain\username».
This also works on Unix systems as well, not just Windows, so it’s a nice cross-platform solution.
One of the easiest ways to find your username is your login screen. Once you start your computer, you’ll see your username appear right at the beginning on top of the password box.
But, if you don’t want to restart your system just to find your username, then read along.
We’ve listed 8 other easy ways to find your username, regardless of the version you are using!
Use the echo command
In computing, the echo command is used to display its arguments on the standard output. We can use this feature to display our username.
- Press Win + R to open the run dialog box.
- Type cmd in the box next to open, and press enter.
- Type echo %USERNAME% and press enter.
- Your username will appear in the next line
Use the whoami command
There is also another way to find your username from the command prompt. You simply need to type out another set of instructions.
- Press Win + R to open the run dialog box.
- Type cmd in the box next to open, and press enter.
- Type whoami and press enter.
- Your username will appear in the next line
Find your username from the Task Manager
In the task manager, there is a tab called users from where you can find your username.
- Press Ctrl + Shift + Esc to open task manager.
- If it appears in compact view, click on the arrow next to more details.
- Go to the users tab.
- If you are a single user, only your username will be shown.
- If there are multiple accounts, your username will be at the top.
Run the Netplwiz command
The Netplwiz.exe is a part of the Microsoft Windows Operating System. It is like an advanced version of the user accounts control panel. You can use this to view and also change your username.
- In the search bar, type Netplwiz.
- From the dialog box that opens, click on properties.
properties”>
- Your windows username will be displayed and highlighted.
Open the control panel
You can also find your username from the control panel.
- Press Windows + R to open the run dialog box.
- Type Control and press enter.
- Go to User Accounts.
user accounts”>
- Press on User Accounts again. Your username will appear right next to your display picture.
Go to the Account Information center
The account information center is where you can find all the details about your user account, from your display picture, password, and obviously, your username.
- Press Ctrl + I to open settings. Go to Accounts.
Accounts”>
- Click on Your Info
- Your username will be displayed in bold below the profile picture
View your username from the start window
You can actually see your username by clicking on the start icon of your screen. However, if your PC is updated to the latest version, you might have to add a couple more steps.
- Click on the start button from your desktop.
- Hover on the profile picture at the left panel.
- Your username will appear there.
And there you have it! We hope you were able to find what your username on Windows is.
Содержание
- Как узнать имя пользователя
- Способ 1: «Командная строка»
- Способ 2: Панель управления
- Вопросы и ответы
Многие пользователи практикуют использование нескольких учётных записей на одном компьютере – например, в целях родительского контроля. Если аккаунтов много, может возникнуть путаница, поскольку не сразу понятно, под каким из них загружена система. Решить этот вопрос можно просмотром имени текущего пользователя, и сегодня мы хотим вас познакомить с методами совершения этой операции.
Как узнать имя пользователя
В более старых вариантах Виндовс псевдоним учётной записи отображался при вызове меню «Пуск», но разработчики отказались от этого в версии «окон» начиная с 8. В сборках «десятки» до 1803 эта возможность вернулась – имя можно было посмотреть через дополнительное меню «Пуска», доступное по нажатию кнопки с тремя полосками. Однако в 1803 и выше это убрали, и в новейшей сборке Windows 10 доступны иные варианты просмотра имени пользователя, приведём самые простые.
Способ 1: «Командная строка»
Множество манипуляций с системой можно совершить с помощью «Командной строки», в том числе и необходимую нам сегодня.
- Откройте «Поиск» и начните набирать словосочетание командная строка. В меню отобразиться нужное приложение – кликните по нему.
- После открытия интерфейса ввода команд укажите в нем следующий оператор и нажмите Enter:
net user
- Команда выведет на экран список всех учётных записей, созданных на этой системе.
К сожалению, никакого выделения текущего пользователя не предусмотрено, поэтому этот способ подходит только для компьютеров с 1-2 учётными записями.
Способ 2: Панель управления
Второй метод, с помощью которого можно узнать имя пользователя – инструмент «Панель управления».
- Откройте «Поиск», наберите в строке панель управления и кликните по результату.
- Режим отображения значков переключите в «Крупные» и воспользуйтесь пунктом «Учётные записи пользователей».
- Щёлкните по ссылке «Управление другой учётной записью».
- Откроется окно, в котором можно просмотреть все учётные записи, существующие на этом компьютере – справа от аватаров каждой из них можно увидеть имена.
Такой способ удобнее, чем задействование «Командной строки», поскольку применять его можно на любой учётной записи, и информацию указанная оснастка отображает более наглядно.
Мы рассмотрели способы, которыми можно узнать имя пользователя компьютера на Windows 10.
Еще статьи по данной теме:
Помогла ли Вам статья?
on October 28, 2010
In Windows OS, we can find the current logged in username from windows command line. The logged in user information is stored in environment variables. So just by printing the value in these environment variables we can get to know the login name.
To know the login name of the currently logged in user we can run the below command.
echo %username%
This works on all releases of Windows OS(Windows XP, Server 2003, Windows Vista and Windows 7).
There is another command whoami which tells us the domain name also.
whoami
Example:
c:\>whoami cmdline\administrator
Both of these options to find user name can be useful in batch files to write code in such a way that it works for every user. For example, if your batch file need to access a user specific folder, say Application data, then you can refer the directory as ‘C:\users\%username%\appdata‘.