;; 
;;=====================================================================================----- 
;; 
;;FUNCTION       OSver() 
;; 
;;ACTION         Returns the O/S version from the local or remote system 
;; 
;;AUTHOR         Glenn Barnas 
;; 
;;VERSION        1.1  - 2016/02/03  
;; 
;;               1.0  - 2003/11/22 - Initial release 
;;               1.0a                Eliminated @DOS and used the registry only. 
;;               1.1  - 2016/02/03 - Updated to use W-10 version data from the  
;;                                   CurrentMajorVersionNumber value instead of  
;;                                   the CurrentVersion value. 
;; 
;;SYNTAX         OSver([target]) 
;; 
;;PARAMETERS     target - Optional - String 
;;               Name of computer to query. Returns local system version if null. 
;; 
;;REMARKS        Universal method to extract a local or remote O/S version value. 
;; 
;;RETURNS        O/S Version value from target system 
;; 
;;DEPENDENCIES   None 
;; 
;;TESTED WITH    WXP through W10, workstation and server platforms  
;; 
;;EXAMPLES       $Ver = OSVer()                ; returns local OS Version 
;;               $Ver = OSVer("\\that_server") ; returns OS Version from "That_Server" 
; 
Function OSVer(Optional $_Target)
 
  Dim $_V					; returned value 
  Dim $_Err					; error code 
 
  If $_Target = ''
    $_Target = @WKSTA
  EndIf
 
  ; insure that '$_Target' has the right format 
  $_Target =  IIf(CStr($_Target) <> '', '\\' + Join(Split(CStr($_Target), '\'), '', 3) + '\', '')
 
 
  ; get the OS value from the target system 
  $_V = ReadValue($_Target + 'HKEY_Local_Machine\SOFTWARE\Microsoft\Windows NT\CurrentVersion', 'CurrentMajorVersionNumber')
  If Not @ERROR
    $_V = $_V + '.' + ReadValue($_Target + 'HKEY_Local_Machine\SOFTWARE\Microsoft\Windows NT\CurrentVersion', 'CurrentMinorVersionNumber')
    $_Err = @ERROR
  Else
    $_V = ReadValue($_Target + 'HKEY_Local_Machine\SOFTWARE\Microsoft\Windows NT\CurrentVersion', 'CurrentVersion')
    $_Err = @ERROR
  EndIf
 
  ; Return a Real number 
  $OSVer = 1.0 * $_V
 
  Exit $_Err
  
EndFunction