Dim strComputer, osVersion, osArch

strComputer = "." 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem",,48) 
For Each objItem in colItems 
	osVersion = Split(objItem.Version, ".")
	If osVersion(0) >= 6 Then
		osArch = Split(objItem.OSArchitecture, " ")
	End If
Next

Call RunInstaller(osVersion, osArch)

Sub RunInstaller(osVersion, osArch)
	Dim regEx, chkStr
	Set regEx = New RegExp
	chkStr = "32"
	regEx.Pattern = Left(osArch(0),2)
	Set oShell = CreateObject("WScript.Shell")
	Select Case osVersion(0)
		Case 5
			Wscript.Echo "*** Illegal environment. ***"
		Case 6
			Select Case osVersion(1)
				Case 0
					Wscript.Echo "*** Illegal environment. ***"
				Case 1
					If regEx.Test(chkStr) Then
						oShell.Run ".\7" & "\setup_win7_x86.exe",1,false
					Else
						oShell.Run ".\7" & "\setup_win7_x64.exe",1,false
					End If
				Case Else
					If regEx.Test(chkStr) Then
						oShell.Run ".\8" & "\setup_win8_x86.exe",1,false
					Else
						oShell.Run ".\8" & "\setup_win8_x64.exe",1,false
					End If
			End Select
		Case 10
			If regEx.Test(chkStr) Then
				oShell.Run ".\10" & "\setup_win10_x86.exe",1,false
			Else
				oShell.Run ".\10" & "\setup_win10_x64.exe",1,false
			end If
		Case Else
			Wscript.Echo "*** Illegal environment. ***"
	End Select

	Set oShell = Nothing

End Sub
