- Windows
- Command Prompt
- Beginner
- 11 min read

These 15 Windows CMD commands answer the questions a support engineer asks first: who is logged in, how long the PC has been running, whether the disk is healthy, and whether Windows is activated. Every command below has an example you can copy and the options you are most likely to need.
Last updated: November 2026
In short
- All 15 commands are built into Windows 10 and Windows 11. Nothing needs to be installed.
- Most of them only read information, so they are safe to try.
- Three need an administrator prompt and some care:
chkdskwith repair options,powercfg /energy, andnetsh wlan export profile key=clear. The last one writes Wi-Fi passwords to disk as readable text.
How to Open Command Prompt
Press Win + R, type cmd and press Enter. For the commands marked “admin” below, open the Start menu, type cmd, and choose Run as administrator.
The commands also work in PowerShell and Windows Terminal, with one exception that is explained under fc. Microsoft documents every option in its Windows commands reference.
All 15 Windows CMD Commands at a Glance
whoamiShows the current user namequery userShows who is logged innet userLists the local user accountswinverShows the Windows version and buildnet stats workstationShows when the PC last startedslmgr /xprShows the Windows activation statusdriverqueryLists the installed driversgetmacShows the MAC address of each adapternetsh wlan export profile key=clearExports saved Wi-Fi profileschkdskScans a disk for errorsdiskmgmt.mscOpens Disk Managementfc file1.txt file2.txtCompares two filesresmonOpens Resource Monitorpowercfg /energyCreates a power efficiency reportdevmgmt.mscOpens Device Manager
Tap a command to jump to it. “admin” = run Command Prompt as administrator.
Who Is Using This PC?
01 whoami: Display the Current User Name
whoami prints the account you are working as, in the form computer\user or domain\user. It is the quickest way to confirm which account a prompt or a script is running under.
whoamiwhoami /groupswhoami /priv/groupslists the groups you belong to. Use it to check whether a user is really in the Administrators group./privlists your privileges. An administrator prompt shows a much longer list than a normal one./allshows everything at once, including the account’s security identifier (SID).
02 query user: Show Logged-in Users
query user lists every user with a session on the machine, with the session name, the state (active or disconnected), the idle time and the logon time. It is most useful on a server that several people reach by Remote Desktop.
query userquery user /server:SERVER01The second command asks another computer, here one named SERVER01. The short form of the command is quser.
Not on Home editions
This command comes with the Pro, Enterprise, Education and Server editions. On Windows Home you will normally see “not recognized as an internal or external command”.
03 net user: List All User Accounts
net user lists the local accounts on the PC. Add an account name to see its details: when the password was last set, when it expires, the last logon, and the groups the account belongs to.
net usernet user Administratornet user jsmith /domainWith /domain, the question goes to the domain controller, not the local PC. That makes it a fast check when a user says “my password stopped working”: look at the “Password expires” and “Account active” lines.
Reading is safe, changing is not
The same command can create accounts and reset passwords when it is given more options in an administrator prompt. The three examples above only read information.
What Is This Machine?
04 winver: Show Windows Version Information
winver opens the small “About Windows” window. It shows the edition, the version (for example 24H2) and the OS build number. Ask for this first when someone reports a problem, because many bugs and fixes belong to one specific build.
winverversysteminfo | findstr /B /C:"OS Name" /C:"OS Version"ver prints the build number as text that you can paste into a ticket. The systeminfo line adds the edition name, such as “Microsoft Windows 11 Pro”.
05 net stats workstation: Check System Uptime
This command prints network statistics. For uptime, read the line near the top that starts with Statistics since and is followed by a date and time. That is when the Workstation service started, which is normally a few seconds after Windows started.
net stats workstationnet stats workstation | find "since"The second command shows only the line you want. For the exact boot time, use systeminfo | find "System Boot Time".
Why uptime can be weeks
Windows 10 and 11 use Fast Startup by default. With it, Shut down saves part of the system to disk and does not count as a fresh start. Only Restart does. So when a user says “I shut it down every night” and the uptime is 30 days, both can be true.
06 slmgr /xpr: Check Windows Activation Status
slmgr /xpr opens a small window that says either “The machine is permanently activated” or the date when the current activation ends. Volume licenses activated through a company KMS server show an end date, because they are valid for 180 days and renew automatically.
slmgr /xprslmgr /dlicscript //nologo %windir%\system32\slmgr.vbs /xpr/dlishows the license type and part of the product key.- The third command prints the answer in the console instead of a pop-up window, which is what you want in a script or a remote session.
07 driverquery: List Installed Drivers
driverquery lists every installed device driver with its name, type and link date. It is helpful after a blue screen that names a driver file, or when you need to compare two machines.
driverquerydriverquery /vdriverquery /sidriverquery /fo csv > drivers.csv/vadds detail, such as whether each driver is running and where its file is./sishows whether each driver is digitally signed, and who made it.- The last command saves the list as a CSV file that opens in Excel.
Network
08 getmac: Show the MAC Address of a Network Adapter
A MAC address is the hardware address of a network adapter. You need it to reserve an IP address in DHCP, to add a device to a Wi-Fi allow list, or to find a device in a switch’s address table.
getmacgetmac /v /fo listPlain getmac prints the addresses with a long device path that is hard to read. The second form adds the connection name (for example “Wi-Fi” or “Ethernet”) and the adapter model, so you can tell which address belongs to which adapter. An adapter that is not connected shows “Media disconnected”.
09 netsh wlan export profile key=clear: Export Saved Wi-Fi Profiles
Windows remembers every Wi-Fi network the PC has joined. This command writes each one to an XML file, one file per network. It is the standard way to move Wi-Fi settings to a new PC.
mkdir C:\wifi-backupnetsh wlan export profile folder=C:\wifi-backup key=clearnetsh wlan add profile filename="C:\wifi-backup\Wi-Fi-Office.xml"- Without
folder=, the files are written to the folder you are in. The folder must already exist. key=clearwrites each password as readable text, inside thekeyMaterialelement of the file. It only does this in an administrator prompt. Without it, the password is stored encrypted and the file is only usable on the same PC.- The third command imports one file on the new PC. The file name here is an example.
To read one forgotten password without creating files, use netsh wlan show profile name="Office" key=clear and look at the “Key Content” line.
These files contain passwords
Anyone who can open the exported files can read your Wi-Fi passwords. Do not put them on a shared drive or send them by email. Import them on the new PC, then delete them. Run this only on computers and networks you are responsible for.
Disks and Files
10 chkdsk: Scan a Disk for Errors
chkdsk checks the file system on a drive. With no options it only reports what it finds, so you can run it at any time.
chkdsk C:chkdsk D: /fchkdsk D: /r/ffixes the file system errors it finds./ralso reads the whole drive to find bad sectors and recover what it can. It includes/f.
A repair needs the drive to itself. For the Windows drive, chkdsk offers to run at the next restart. Answer Y and restart when the user can wait.
Back up first, and plan the time
On a large hard disk, /r can run for several hours, and the PC cannot be used until it finishes. If you suspect the disk is failing, copy the important data off it before you run a repair.
11 diskmgmt.msc: Open Disk Management
This opens the Disk Management console, which shows every disk and its partitions as a picture. Use it to bring a new disk online, create or format a volume, change a drive letter, or extend and shrink a partition.
diskmgmt.mscIt is the first place to look when a new or external drive is connected but does not appear in File Explorer. Usually the disk is there with no drive letter, or it is not yet initialized.
12 fc: Compare Two Files
fc (file compare) shows the lines that differ between two files. It is good for a quick answer to “what changed in this configuration file?”
fc file1.txt file2.txtfc /n old.conf new.conffc /b image1.iso image2.iso/nshows line numbers./cignores the difference between capital and small letters./bcompares byte by byte, for files that are not text.
If the files are the same, the answer is “FC: no differences encountered”.
In PowerShell, type fc.exe
In PowerShell, fc is a short name for a different command (Format-Custom), so the result looks wrong. Type fc.exe file1.txt file2.txt to get the file comparison.
Performance, Power and Hardware
13 resmon: Open Resource Monitor
Resource Monitor shows more than Task Manager. It has five tabs: Overview, CPU, Memory, Disk and Network.
resmonIt can answer these three questions:
- What is keeping the disk at 100%? The Disk tab lists the files being read and written, with the process behind each one.
- Which program is using the network? The Network tab shows each process with the addresses it is talking to.
- Which program has this file locked? On the CPU tab, type the file name in the “Associated Handles” search box.
14 powercfg /energy: Generate a Power Efficiency Report
This command watches the PC for 60 seconds, then writes a report named energy-report.html. The report lists errors and warnings: devices that stop the PC from sleeping, USB devices that never suspend, and processes that keep the processor busy.
powercfg /energy /output C:\Temp\energy-report.htmlpowercfg /batteryreport /output C:\Temp\battery-report.html- Close other programs and do not touch the PC during the 60 seconds, so the report shows the PC at rest. The folder in
/outputmust already exist. - Without
/output, the report is written to the current folder. In an administrator prompt that is normallyC:\Windows\System32. - On a laptop, the second command creates a battery report. Compare “Design capacity” with “Full charge capacity” to see how worn the battery is.
15 devmgmt.msc: Open Device Manager
Device Manager lists every piece of hardware Windows has found. A yellow warning mark means a device has a problem, most often a missing or wrong driver. Open the device, and the Device status box gives an error code you can search for.
devmgmt.mscpnputil /enum-devices /problemThe second command lists only the devices that have a problem, as text, without opening a window. It works on Windows 10 version 1903 and later.
From the Driver tab you can update a driver, or use Roll Back Driver when a problem started right after an update.
A Five-Minute Health Check
When a user says their PC “is slow” or “acts strange”, run these commands in this order.
Run
whoamiandwinver. You now know the account and the exact Windows build.Run
net stats workstation | find "since". If the PC has been up for weeks, restart it before anything else.Open
resmonand look for one process that holds the CPU, the memory or the disk.Run
chkdsk C:with no options. If it reports problems, back up, then plan a repair.Open
devmgmt.mscand look for yellow warning marks.Save the facts for your ticket:
driverquery /fo csv > drivers.csvandgetmac /v /fo list.
Frequently Asked Questions
Do these commands work on both Windows 10 and Windows 11?
Yes, they ship with both. The exception is query user, which Home editions normally do not include.
Which of these commands can change my system?
chkdsk with /f or /r repairs the disk, and netsh wlan export profile creates files that hold passwords. Disk Management and Device Manager can make large changes, but only when you choose an action inside them. The rest only show information.
Why do I get “Access is denied”?
The command needs an administrator prompt. Open the Start menu, type cmd, and choose Run as administrator.
Can I save the output of a command to a file?
Yes. Add > file.txt to the end, for example net user > users.txt. Use >> to add to a file without replacing what is in it.
Key Takeaways
whoami,winverand the uptime line fromnet stats workstationgive you the account, the build and the time since the last start.- With Fast Startup on, only Restart gives Windows a fresh start; Shut down does not.
chkdskwith no options only reports. Back up before you add/for/r.- Exported Wi-Fi profiles hold readable passwords. Delete them once the new PC has them.
- In PowerShell, type
fc.exe, because plainfcrunsFormat-Customthere.
