开发者

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 w开发者_StackOverflow社区ant 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 ~
$
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜