Knowing the exact version of Windows running on a machine is a fundamental task for any administrator or power user. The command line offers a precise and efficient way to retrieve this information without navigating through graphical settings. This method is invaluable for scripting, remote management, and quickly verifying system details.
Opening Command Prompt with Elevated Privileges
Before executing version checks, it is often necessary to open Command Prompt as an administrator. Right-click the Start button and select "Command Prompt (Admin)" or "Windows PowerShell (Admin)". Running with elevated privileges ensures access to all system-level queries and prevents permission-related errors, especially when managing multiple machines.
Using the systeminfo Command
The systeminfo command provides the most comprehensive overview of the operating system and hardware. It outputs a detailed list including the exact OS version, build number, installation date, and service pack status. To filter for specific details like the OS version, you can pipe the output through the findstr command:
Leveraging the winver Shortcut
While not strictly a command line executable from a pure terminal prompt, invoking winver opens the "About Windows" dialog box instantly. This graphical window displays the edition, version, and build number in a user-friendly format. It serves as a quick visual confirmation when direct terminal output is not required for logging or scripting.
Querying the Registry Directly
For script automation or deep system inspection, querying the registry is the most direct approach. The release ID is stored in a specific key and can be retrieved using the reg query command. This technique is highly reliable for batch files and complex scripts:
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentBuild
Utilizing PowerShell cmdlets
PowerShell provides modern cmdlets that return structured objects, making parsing significantly easier than parsing plain text. The Get-CimInstance cmdlet retrieves the Win32_OperatingSystem class, offering properties like Caption and Version . This method is preferred for advanced scripting due to its clean output format:
Interpreting Build Numbers
Windows versions are often identified by their build numbers rather than marketing names. A build number like 19041 corresponds to Windows 10 20H2, while 22000 indicates Windows 11. Understanding this mapping allows users to pinpoint the exact release and update level of their installation, which is crucial for troubleshooting compatibility issues.
Verifying Version on Remote Machines
System administrators frequently need to check versions across a network without physical access. Tools like PsExec from the Sysinternals suite allow you to execute the version commands remotely. By combining psexec \\RemotePC -u User -p Pass cmd /c "systeminfo" , you can gather intelligence on multiple systems from a single console, streamlining network inventory management.