How to find out what OS I'm running on?

Asked by Gorilla

Is there a way I can determine if my script is running on Windows 7 or Windows XP?

Thanks.

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
j (j-the-k) said :
#1

You should try one of these:

1.
import os
myOS = os.environ.get('OS')

2.
import os
myOS = os.name

3.
import sys
myOS = sys.platform

I don't know which of these works for your problem because I don't have a windows here to test it, but I hope one of these methods is the right one.

Revision history for this message
RaiMan (raimund-hocke) said :
#2

... and you have Sikuli's Env class with it's features
http://sikuli.org/docx/globals.html#Env.getOS

Revision history for this message
Gorilla (ksperry2) said :
#3

It turns out that os.name yields - java
os.getenv yields - Windows_NT
sys.platform yields - java1.6.0_32

Looks like I will have to pick one of the environment variables that has the user path defined. WIN7 has a path of C:\Users\[user]. WINXP has a path of C:\Documents and Settings\[user]. (My target machines are only WIN7 or WINXP)

Thanks for your help.

Gorilla

Revision history for this message
RaiMan (raimund-hocke) said :
#4

What about comment #2 ???????????

Can you help with this problem?

Provide an answer of your own, or ask Gorilla for more information if necessary.

To post a message you must log in.