简体   繁体   English

在 Cygwin 中获取 windows 版本

[英]Get windows version in Cygwin

How can I get the windows version I am currently running under Cygwin?如何获得我目前在 Cygwin 下运行的 windows 版本?

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.我正在维护一个在 Mac、Windows 和 Linux 发行版上运行的自动构建脚本,我需要能够检测它当前运行的 Windows 版本。

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.最好我可以让它返回标准的 Windows 版本名称,但我可以与其他代码分开的某种代码也很棒。

What I want to know is if I am running 7, XP, Server 2008 and so on.我想知道我是否在运行 7、XP、Server 2008 等。

Help, Ideas?帮助,想法?

You can grep it out of the Windows systeminfo utility.您可以从 Windows systeminfo实用程序中取出 grep。

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:您可以使用uname -s并将 output 与此进行比较:

NT-5.0 = W2000 NT-5.0 = W2000

NT-5.1 = XP NT-5.1 = 经验值

NT-6.0 = Vista NT-6.0 = 远景

NT-6.1 = W7 NT-6.1 = W7

I'm running Windows 7 64 bit, so my output is: CYGWIN_NT-6.1-WOW64 .我正在运行 Windows 7 64 位,所以我的 output 是: 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 ~
$

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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