简体   繁体   中英

Get windows version in Cygwin

How can I get the windows version I am currently running under Cygwin?

I am maintaining a automatic build script that is running on Mac, Windows and Linux distributions and I need to be able to detect what Windows version it is currently running under.

Preferably I could have it return the standard Windows release name but some kind of code that I can separate from the other ones would also be great.

What I want to know is if I am running 7, XP, Server 2008 and so on.

Help, Ideas?

You can grep it out of the Windows systeminfo utility.

systeminfo | grep '^OS'

OS name only:

systeminfo | sed -n 's/^OS Name:[[:blank:]]*//p'

Example:

$ systeminfo.exe | grep '^OS'
OS Name:                   Microsoft Windows 7 Home Premium
OS Version:                6.1.7601 Service Pack 1 Build 7601
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Standalone Workstation
OS Build Type:             Multiprocessor Free
$ systeminfo | sed -n 's/^OS Name:[[:blank:]]*//p'
Microsoft Windows 7 Home Premium

You could use uname -s and compare the output to this:

NT-5.0 = W2000

NT-5.1 = XP

NT-6.0 = Vista

NT-6.1 = W7

I'm running Windows 7 64 bit, so my output is: CYGWIN_NT-6.1-WOW64 . You can see more information here .

Like this:

eh@winxpsp3 ~
$ echo `cmd /c ver`
 Microsoft Windows XP [Version 5.1.2600]

eh@winxpsp3 ~
$

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM