Jared
Jared

Reputation: 1897

Find out windows version from non-privileged user command line

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.

Upvotes: 15

Views: 40046

Answers (6)

Sriniv
Sriniv

Reputation: 131

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

Upvotes: 12

Nior aon Duine
Nior aon Duine

Reputation: 21

if not CMDEXTVERSION 2 (
  echo Error: This batch requires Command Extensions version 2 or higher
  exit /b 1
)

FOR /F "usebackq tokens=4 delims=] " %%I IN (`ver`) DO for /F "tokens=1,2 delims=." %%J IN ("%%I") do set WindowsVersion=%%J.%%K
if "%WindowsVersion%" LSS "6.1" (
  echo Error: This batch requires Windows 7 SP1 or higher
  exit /b 1
)

Upvotes: 2

user5419367
user5419367

Reputation: 1

You can get the SysInternals and install onto your C:\ directory. After that you can then go to a command prompt and use the command PSINFO.

It is great because it lets me query any PC on the network (that I have access to). At the command prompt you type: PSINFO \exactnameofcomputer

(PSINFO whack whack exactnameofcomputer)

Then hit enter. It will take a moment or two to report back, depending on where that computer is located at.

Upvotes: 0

Jared
Jared

Reputation: 1897

I solved this problem by parsing the output of:

reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v "ProductName"

Upvotes: 20

Joey
Joey

Reputation: 354774

cmd displays the Windows version when started:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Joey>_

This is also a similar line as the one ver spits out, indeed.

One option then might be

echo exit|cmd|findstr Windows

another

cmd /c ver

depending on whether you have a pipeline or not.

Upvotes: 4

Caleb Jares
Caleb Jares

Reputation: 6307

You can use ver. I'm on a school computer with a non-privileged command prompt, and it gives me Microsft Windows [Version 6.1.7601]. I'm sure you'd be able to sort out Vista and XP from the number you get.

Upvotes: 5

Related Questions