You can do that with the help of the environment variable. The exact variable is, OS and OSVersion are for the version information.