User Tools

Site Tools


userspace:library:getmsversionmap

getMsVersionMap.opsiinc


read OS version and OS Type…

Tested with opsi 4.0.4
requiredWinstVersion >= 4.11.2.
By GEI 2014/11/11 19:00

placed in global library, such as %ScriptDrive$/lib … call with

include_insert %ScriptDrive%/lib/getmsversionmap.opsiinc
; This sourcecode is partly owned by uib.de
; and published under the Terms of the General Public License.
; credits: http://www.opsi.org/en/credits/
;
; written by GEI (Detlef Krummel  opsi@gei.de)
; FILE "%ScriptDrive%\lib\getmsversionmap.opsiinc"
 
requiredWinstVersion >="4.11.2"
; for debugging  setLogLevel = 7
; based on: 
; 	https://download.uib.de/opsi_stable/doc/html/opsi-winst-manual/opsi-winst-manual.html#opsi-winst-stringlist-maps
; 	http://msdn.microsoft.com/en-us/library/ms724834%28v=vs.85%29.aspx
; 	http://msdn.microsoft.com/en-us/library/ms724833%28v=vs.85%29.aspx
 
; for debugging setLogLevel = 7
DefStringList 	$MsVersionMap_List$
Set 		$MsVersionMap_List$	= GetMsVersionMap
setLogLevel = 6
 
; ----- sample values ------------------------------------------------------------------------
; 0)major_version=5		1)minor_version=1		2)build_number=2600
; 3)platform_id=2		4)csd_version=Service Pack 3	5)service_pack_major=3
; 6)service_pack_minor=0	7)suite_mask=256		8)product_type_nr=1
; 9)2003r2=false
 
DefVar		$MsVersionMap_MajorVersion$
Set		$MsVersionMap_MajorVersion$	= takeString( 0,$MsVersionMap_List$)
DefVar		$MsVersionMap_MinorVersion$
Set		$MsVersionMap_MinorVersion$	= takeString( 1,$MsVersionMap_List$)
DefVar		$MsVersionMap_BuildNumber$
Set		$MsVersionMap_BuildNumber$	= takeString( 2,$MsVersionMap_List$)
DefVar		$MsVersionMap_PlatformId$
Set		$MsVersionMap_PlatformId$	= takeString( 3,$MsVersionMap_List$)
DefVar		$MsVersionMap_CsdVersion$
Set		$MsVersionMap_CsdVersion$	= takeString( 4,$MsVersionMap_List$)
DefVar		$MsVersionMap_ServicePackMajor$
Set		$MsVersionMap_ServicePackMajor$	= takeString( 5,$MsVersionMap_List$)
DefVar		$MsVersionMap_ServicePackMinor$
Set		$MsVersionMap_ServicePackMinor$	= takeString( 6,$MsVersionMap_List$)
DefVar		$MsVersionMap_SuiteMask$
Set		$MsVersionMap_SuiteMask$	= takeString( 7,$MsVersionMap_List$)
DefVar		$MsVersionMap_ProductTypeNr$
Set		$MsVersionMap_ProductTypeNr$	= takeString( 8,$MsVersionMap_List$)
DefVar		$MsVersionMap_2003r2$
Set		$MsVersionMap_2003r2$		= takeString( 9,$MsVersionMap_List$)
 
; ---------------------- additional: define and set $WinOS$ -----------------------------------------
DefVar		$WinOS$
Set 		$WinOS$ = "unknown"
 
; @UIB:  spagetti code, a CASE structur is absolutely desirable ... 
; https://forum.opsi.org/viewtopic.php?f=5&t=5303 
 
if  $MsVersionMap_ProductType$ = "1" 
	; Client OS
  	if $MsVersionMap_MajorVersion$ = "5"
		Set $WinOS$ = "WinXP"
  	else
  		if $MsVersionMap_MajorVersion$ = "6"
	    		if $MsVersionMap_MinorVersion$ = "0"
      				Set $WinOS$ = "WinVista"
    			else
      				if $MsVersionMap_MinorVersion$ = "1"
        				Set $WinOS$ = "Win7"
      				else
        				if $MsVersionMap_MinorVersion$ = "2"
          					Set $WinOS$ = "Win8"
        				else
          					if $MsVersionMap_MinorVersion$ = "3"
            						Set $WinOS$ = "Win8.1"
						else
							if $MsVersionMap_MinorVersion$ = "4"
								set $WinOS$ = "Win9 ?"
							endif
						endif
          				endif
        			endif
      			endif
    		endif
		; Major not 5 or 6
		set $WinOS$ = "Client unknown"
	endif
else
	; Server OS
	if $MsVersionMap_ProductType = "2" 
		Set $WinOS$ = "NT-Domaincontroler"
	else
		if $MsVersionMap_ProductType = "3" 
			Set $WinOS$ = "NT-Server"
		else
			Set $WinOS$ = "WinProductType unknown"
		endif
	endif
endif
userspace/library/getmsversionmap.txt · Last modified: 2021/08/23 08:37 (external edit)