0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

OSバージョン取得 VBScript (備忘録)

Last updated at Posted at 2022-12-28
Wscript.Echo GetOSVersion()

' **********************************************************
' Windows 2000 : 5
' Windows XP   : 5.1
' Windows 7    : 6.1
' Windows 8    : 6.2
' Windows 8.1  : 6.3
' Windows 10   : 10
' **********************************************************
Function GetOSVersion()

	Dim obj,colTarget,objRow,str,aData,nData,I

	Set obj = GetObject("winmgmts:\\.\root\cimv2")
	Set colTarget = obj.ExecQuery( "select * from Win32_OperatingSystem" )
	For Each objRow in colTarget
		str = objRow.Version
	Next

	aData = Split( str, "." )
	For I = 0 to Ubound( aData )
		if I > 1 then
			Exit For
		end if
		if I > 0 then
			nTarget = nTarget & "."
		end if
		nTarget = nTarget & aData(I)
	Next

	GetOSVersion = CDbl( nTarget )

End Function
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?