用于确定操作系统类型的环境变量(Windows XP、Windows 7)
我想在 XML 文件中区分 Windows XP 和 Windows 7。我想我会在 XML 中使用环境变量。
但是我找不到 Windows 中定义的任何提供此信息的系统环境变量。
我看到 %OSTYPE% 变量,但它仅在 Windows 7 中可用。它在 XP 中未定义。
无论如何我可以做到这一点吗?
请注意,我想要一个完全依赖于系统环境变量的解决方案。我不想基于执行某些命令来创建新变量,因为我想在 XML 文件中使用此变量。
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.
However I could not find any system environment variable defined in windows that gives this information.
I see the %OSTYPE% variable but it is only available in Windows 7. It is not defined in 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,XP 中的环境变量是“OS”。
请参阅:
http://www.techrepublic.com/article/understanding- windows-xps-环境变量/5986211
Near as I can tell the environment variable in XP is "OS".
See:
http://www.techrepublic.com/article/understanding-windows-xps-environment-variables/5986211
没有完全预设的环境变量,但是...
这个文章来自微软,它引用了一个名为
gettype.exe
的程序,我不知道这是不是内置的。我没有在 Windows 上进行测试。无论如何,也许它对你有帮助。还有看起来内置的
ver
- 这是一个使用它的示例脚本。No exactly preset environment variables but...
This article is 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.There's also
ver
which looks built-in - here's an example script using that.