2007/10/03

Vbscript - 설치된 Windows 비스타 버젼 확인

다음 스크립트는 설치된 윈도우 비스타의 버젼을 알아보는 스크립트 입니다. WMI 를 이용하는 방법입니다.

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * From Win32_OperatingSystem")

For Each objItem in colItems
    If Instr(objItem.Caption, "Vista") Then
        Select Case objItem.OperatingSystemSKU
             Case 0 strVersion = "Undefined."
             Case 1 strVersion = "Ultimate Edition."
             Case 2 strVersion = "Home Basic Edition."
             Case 3 strVersion = "Home Basic Premium Edition."
             Case 4 strVersion = "Enterprise Edition."
             Case 5 strVersion = "Home Basic N Edition."
             Case 6 strVersion = "Business Edition."
             Case 7 strVersion = "Standard Server Edition."
             Case 8 strVersion = "Datacenter Server Edition."
             Case 9 strVersion = "Small Business Server Edition."
             Case 10 strVersion = "Enterprise Server Edition."
             Case 11 strVersion = "Starter Edition."
             Case 12 strVersion = "Datacenter Server Core Edition."
             Case 13 strVersion = "Standard Server Core Edition."
             Case 14 strVersion = "Enterprise Server Core Edition."
             Case 15 strVersion = "Enterprise Server IA64 Edition."
             Case 16 strVersion = "Business N Edition."
             Case 17 strVersion = "Web Server Edition."
             Case 18 strVersion = "Cluster Server Edition."
             Case 19 strVersion = "Home Server Edition."
             Case 20 strVersion = "Storage Express Server Edition."
             Case 21 strVersion = "Storage Standard Server Edition."
             Case 22 strVersion = "Storage Workgroup Server Edition."
             Case 23 strVersion = "Storage Enterprise Server Edition."
             Case 24 strVersion = "Server For Small Business Edition."
             Case 25 strVersion = "Small Business Server Premium Edition."

        End Select
        Wscript.Echo "This computer is running Windows Vista " & strVersion
    Else
        Wscript.Echo "This computer is not running Windows Vista."
    End If
Next

위 스크립트의 경우 로컬 컴퓨터의 정보를 조회하는 것이지만,. 네트워크에 다른 컴퓨터도 조회가 가능합니다. 다만 해당 컴퓨터에 접속 가능한 RPC 권한이 있어야 합니다.


Active Directory 환경에서는 해당 도메인에 속해 있는 컴퓨터 목록을 쉽게 쿼리가 가능하므로 해당 도메인의 모든 컴퓨터의 OS 환경을 정리할수 있겠죠..^^

다음 스크립트는, Active Directory 에서 컴퓨터 목록을 조회하는 스크립트 입니다.

On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

objCommand.CommandText = _
    "SELECT CN FROM 'LDAP://dc=fabrikam,dc=com' WHERE objectCategory='computer'" 
Set objRecordSet = objCommand.Execute

objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    strComputer = objRecordSet.Fields("Name").Value

    Set objWMIService = GetObject _
        ("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery _
        ("Select * From Win32_OperatingSystem")
    For Each objItem in ColItems
        Wscript.Echo strComputer & ": " & objItem.Caption
    Next

    objRecordSet.MoveNext
Loop





03-TechNetB_masthead_ltr.gif

댓글 없음:

댓글 쓰기

가장 많이 본 글