Since Windows 2000, the whoami
command has been part of the standard command line (thanks to pk for clearing that up in comments!).
You can do this: Open a command prompt and type “set” then hit enter. This shows active environment variables. Current logged on username is stored in the USERNAME env variable and your domain is stored in the USERDOMAIN variable.
To piggy-back off the other answers, from a cmd line:
echo %USERDOMAIN%\%USERNAME%
will get you the complete logged on user in domain\username format.
You can do the same thing with Powershell with this:
write-host $env:userdomain\$env:username
Related Posts:
- What’s the command-line utility in Windows to do a reverse DNS look-up?
- Useful Command-line Commands on Windows
- Resolve host name from IP address
- Run a .bat file in a scheduled task without a window
- Does Windows have a built-in ZIP command for the command line?
- How can I connect to a Windows server using a Command Line Interface? (CLI)
- What exactly are DLL files, and how do they work?
- The application was unable to start correctly (0xc000007b)
- ‘npm’ is not recognized as internal or external command, operable program or batch file
- Difference between xcopy and robocopy
- The filename, directory name, or volume label syntax is incorrect inside batch
- Bat file to run a .exe at the command prompt
- How can I open Java .class files in a human-readable way?
- Opening a remote machine’s Windows C drive
- Why does CreateProcess give error 193 (%1 is not a valid Win32 app)
- Taskkill /f doesn’t kill a process
- Bluescreen on windows 10 after using android emulator
- XCOPY: Overwrite all without prompt in BATCH
- How to install and run the Nmap program through Cygwin in Windows?
- How to compile C program on command line using MinGW?
- All links in my site start with localhost?
- WordPress database setup Windows 2016 IIS
- How do you find what process is holding a file open in Windows?
- How do I tell Git for Windows where to find my private RSA key?
- How to send ctrl+alt+del using Remote Desktop?
- How do you add a Windows environment variable without rebooting?
- hosts file ignored, how to troubleshoot?
- How to refresh hosts file without rebooting
- How to sleep in a batch file?
- Command line to list users in a Windows Active Directory group?
- What is Active Directory Domain Services and how does it work?
- Is there a global, persistent CMD history?
- How do I diff two text files in Windows Powershell?
- In Windows, using the command line, how do you check if a remote port is open?
- Can you run Docker natively on the new Windows 10 (Ubuntu) bash userspace?
- How does CTRL-ALT-DEL to log in make Windows more secure?
- How to check if a port is blocked on a Windows machine?
- How do I force sync the time on Windows Workstation or Server?
- How do I create a symbolic link in Windows?
- Best practice: Should I always install a fresh OS for new employees?
- How can I tell what version of IIS is installed?
- Where can I find data stored by a Windows Service running as “Local System Account”?
- What’s the reverse DNS command line utility?
- Windows server last reboot time
- Windows Active Directory naming best practices?
- Why hasn’t rsync caught on in the Windows world? [closed]
- Boot and Install Windows from a USB thumb drive
- How to fix PuTTY showing garbled characters? [closed]
- How to delete cached temporarily credentials for a network share on a Windows machine without rebooting or logging off [duplicate]
- How do you free up a port being held open by dead process?
- How to configure a Windows machine to allow file sharing with a DNS alias
- Alternatives to Splunk?
- How to fix “VirtualBox Interface has active connections” error in Windows?
- outputting ascii table in C++
- Tensorflow import error: No module named ‘tensorflow’
- A fatal error occurred while creating a TLS client credential. The internal error state is 10013
- How can I install pip on Windows?
- bash: npm: command not found?
- Setting Windows PowerShell environment variables
- finding dll for “The specified module could not be found”
- Windows 7 exception code: 0xc0000409
- What languages are Windows, Mac OS X and Linux written in?
- How can I open the Atom editor from the command line in OS X?
- stop all instances of node.js server
- LNK1168: cannot open debug\file.exe for writing
- Command line for looking at specific port
- Windows Activator .bat Text
- “rm -rf” equivalent for Windows?
- VC++ fatal error LNK1168: cannot open filename.exe for writing
- Xampp MySQL not starting – “Attempting to start MySQL service…”
- Python 3.2 Unable to import urllib2 (ImportError: No module named urllib2)
- How to stop Python closing immediately when executed in Microsoft Windows
- Anaconda Installed but Cannot Launch Navigator
- “Javac” doesn’t work correctly on Windows 10
- SVN admin management GUI tool
- How can I run a program from a batch file without leaving the console open after the program starts?
- What exactly is the scope of Access Violation ‘0xc0000005’?
- Open File in Another Directory (Python)
- batch file from scheduled task returns code 2147942401
- In Windows cmd, how do I prompt for user input and use the result in another command?
- CALL command vs. START with /WAIT option
- BAT file to map to network drive without running as admin
- Javac “cannot find symbol”
- How to use/install GNU binutils (objdump)
- Anaconda “failed to create process”
- “NODE_ENV” is not recognized as an internal or external command, operable command or batch file
- Batch command for ImageMagick to convert all files in a directory and sub-directories on windows
- how to empty recyclebin through command prompt?
- moving server can not login
- Why doesn’t WP_PLUGIN_DIR definition use DIRECTORY_SEPARATOR?
- Offline WordPress Application
- wordpress http to https windows server
- One-click WP site generation wih wp-cli on Windows
- FTP Connection Information after Installation in Cygwin
- WAMP SERVER Command Prompt SET PATH=%PATH%
- Migrating WordPress from Windows Server 2008 R2 (IIS v7.5) to CentOS
- Perfmon performance counters on WAMP
- How to cd into a directory with this name “-2” (starting with the hyphen)?
- How to add dependency on a Windows Service AFTER the service is installed
- How can I get diff to show only added and deleted lines? If diff can’t do it, what tool can?