You can use WMI to get this information. It should work on most systems with recent versions of Windows (probably not on 9x systems). The following generic $wmi() identifier can be used to easily retrieve the OS version info:
Code:
; $wmi(class,N,property[,timeout])
; class: name of the WMI class to be used
; N: the Nth class instance. N can be 0, to return the total number of instances
; property: the property of interest (ignored if N = 0)
; timeout (optional): number of seconds the COM connection is kept open (default is 120 seconds)
alias wmi {
  if $0 < 2 || ($0 == 2 && $2 != 0) { return }
  if !$com($1) {
    .comopen $1^loc WbemScripting.SWbemLocator
    if ($comerr) return
    .comclose $1^loc $com($1^loc,ConnectServer,3,dispatch* $1^con)
    if ($com($1^con)) .comclose $v1 $com($v1,InstancesOf,3,bstr*,$1,dispatch* $1)
    if (!$com($1)) return
  }
  .timerwmi: $+ $1 -oi 1 $iif($0 > 2 && $($ $+ $0,2) isnum 0-,$v1,120) if ($com( $1)) .comclose $1
  if ($2 == 0) return $comval($1,$2)
  return $comval($1,$2,$3)
}
Then you can try this:

//echo -ag $wmi(Win32_OperatingSystem,1,Caption) $iif($wmi(Win32_OperatingSystem,1,ServicePackMajorVersion),SP $+ $v1)

You can use any of the properties listed here if you need more information (eg BuildNumber).

Edit: small correction

Last edited by qwerty; 20/09/08 12:04 PM.

/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com