faqts : Computers : Programming : Languages : Python : Snippets

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

1 of 3 people (33%) answered Yes
Recently 0 of 2 people (0%) answered Yes

Entry

Getting Windows version

Jul 5th, 2000 10:03
Nathan Wallace, Hans Nowak, Snippet 356, Emile van Sebille


"""
Packages: operating_systems.windows
"""
"""
By the way, in windows at a command prompt:
95,98:    net config
nt:       net config [server|workstation]
gives a line that starts : Software version
I thought I'd key in it a script real quick, but I don't have
enough time now to wrap it up.  Maybe it will get you started.
"""
import sys
def getwinver():
 import os
 winver = None
 test = os.system('net config > xxconfig.net')
 if test == 0:
  f = open('xxconfig.net', 'r')
  config = f.readlines()
  f.close()
  for line in config:
   #print line
   sys.stdout.write(line)
   if line[:16] == "Software version":
    winver = line
 else:
  pass # test value is error code
 return winver
if __name__ == "__main__":
    print getwinver()