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

為{幸葍}努か 提交于 2019-12-19 10:52:15

问题


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.


回答1:


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.




回答2:


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

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

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



来源:https://stackoverflow.com/questions/2788720/environment-variable-to-determine-the-os-type-windows-xp-windows-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!