Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find out windows version from non-privileged user command line

Tags:

windows

cmd

I need a way to find out what version of windows I'm running in using simple command line tools (no powershell). I need it to work from a non-privileged user, and I need to be able to parse out the difference between Windows XP, Vista, server 2008, and 7. I'm currently using: wmic os get Caption but that fails when the user doesn't have permissions to run wmic.

Update: To clarify, I need this command to not break with different service pack levels, etc. which probably rules out parsing a specific version number. Also if you look at this list of windows versions, you'll see that the numbers reported on Windows 7 and server 2008 r2 are the same.

like image 446
Jared Avatar asked Dec 05 '11 17:12

Jared


2 Answers

I solved this problem by parsing the output of:

reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v "ProductName"
like image 157
Jared Avatar answered Oct 09 '22 08:10

Jared


systeminfo command shows everything about the os version including service pack number and the edition you are using.

C:\>systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
OS Name:                   Microsoft Windows 7 Enterprise
OS Version:                6.1.7601 Service Pack 1 Build 7601    

Reference: Find Windows version from command prompt

like image 25
Sriniv Avatar answered Oct 09 '22 07:10

Sriniv