1

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.

Santhosh
  • 6,547
  • 15
  • 56
  • 63
  • Possible dupe - http://stackoverflow.com/questions/57124/how-to-detect-true-windows-version – ChrisF May 07 '10 at 13:09
  • @ChrisF, that question actually talks about detecting the Windows version by any available means (mostly by APIs). Not necessarily System Environment Variables. – Santhosh May 07 '10 at 13:12
  • Which is why I just commented rather than voting to close. Do any of the answers help at all? – ChrisF May 07 '10 at 13:13
  • Actually not. I am inside a XML file and i do not have access to any of the APIs from that file. However, it if were a environment variable, it would just expand itself and i would accomplish what i wanted to do.. – Santhosh May 07 '10 at 13:28
  • Ah well. There doesn't appear to be an XP specific environment variable (at least that I can see). – ChrisF May 07 '10 at 13:31

2 Answers2

6

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

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Fernmae
  • 61
  • 1
  • 2
  • 4
    The "OS" environment variable has the value "Windows_NT" on at least the following systems: Windows XP, Windows 2000 and Windows 7. I don't know about other Windows flavours, but it seems likely to be the same on those as well. Perhaps someone else could confirm. – edam Jan 04 '13 at 16:41
  • 1
    "OS" is "Windows_NT" on Windows 10 and the server operating systems as well. So that's not very helpful unless you're on Windows98 or earlier. – UweBaemayr Sep 06 '16 at 20:46
0

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.

Ben N
  • 2,883
  • 4
  • 26
  • 49
zaf
  • 22,776
  • 12
  • 65
  • 95
  • These samples make use of running utility command or programs to determine the type of the OS. I was wondering if it is possible by just using environment variables? – Santhosh May 07 '10 at 13:27