确定操作系统类型的环境变量(Windows XP、Windows 7)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2788720/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 07:18:30  来源:igfitidea点击:

Environment Variable to determine the OS type (Windows XP, Windows 7)

windowswindows-7windows-xpenvironment-variables

提问by Santhosh

I want to differentiate between Windows XP and Windows 7 in a XML file. Thought i will use an environment variable for it inside the XML.

我想在 XML 文件中区分 Windows XP 和 Windows 7。以为我会在 XML 中使用环境变量。

However I could not find any system environment variable defined in windows that gives this information.

但是,我找不到在 Windows 中定义的任何提供此信息的系统环境变量。

I see the %OSTYPE% variable but it is only available in Windows 7. It is not defined in XP.

我看到了 %OSTYPE% 变量,但它只在 Windows 7 中可用。它在 XP 中没有定义。

Is there anyway i could do this?

无论如何我可以做到这一点吗?

Note that i would like a solution which purely depends on system environment variables. I do not want to create new variables based on executing some command, because i want to use this variable in a XML file.

请注意,我想要一个完全取决于系统环境变量的解决方案。我不想基于执行某些命令创建新变量,因为我想在 XML 文件中使用这个变量。

采纳答案by zaf

No exactly preset environment variables but...

没有完全预设的环境变量,但是...

This articleis from Microsoft and it refers to a program called gettype.exe, I don't know if this is a built-in or not. I'm not on Windows to test. Anyway, maybe it helps you.

这篇文章来自微软,它指的是一个名为 的程序gettype.exe,我不知道这是不是内置的。我不是在 Windows 上进行测试。不管怎样,也许对你有帮助。

There's also verwhich looks built-in - here's an example scriptusing that.

还有ver看起来是内置的 -这是一个使用它的示例脚本

回答by Fernmae

Near as I can tell the environment variable in XP is "OS".

就我所知,XP 中的环境变量是“OS”。

OS: Lists the name of the operating system. (Windows XP and Windows 2000 list the operating system as Windows_NT.)

OS:列出操作系统的名称。(Windows XP 和 Windows 2000 将操作系统列为 Windows_NT。)

See: http://www.techrepublic.com/article/understanding-windows-xps-environment-variables/5986211

请参阅:http: //www.techrepublic.com/article/understanding-windows-xps-environment-variables/5986211