#navi(../)
* Win32_ComputerSystemProductのサンプルスクリプト [#n93167f8]
WMIを使ったWin32_ComputerSystemProductでマシンに関する情報を表示するサンプルスクリプトを以下に記します。

#contents
#htmlinsertpcsp(win-top.html,win-sp.html)

* 関連記事 [#rfdd5bef]
-[[PowerShellでWMIを使用するサンプル>PowerShell/PowerShellでWMIを使用するサンプル]]
-[[Win32_ComputerSystemのサンプルスクリプト>WSH/Win32_ComputerSystemのサンプルスクリプト]]
-[[Win32_ComputerSystemProductのサンプルスクリプト>WSH/Win32_ComputerSystemProductのサンプルスクリプト]]
-[[Win32_OperatingSystemのサンプルスクリプト>WSH/Win32_OperatingSystemのサンプルスクリプト]]
-[[Win32_BIOSのサンプルスクリプト>WSH/Win32_BIOSのサンプルスクリプト]]
-[[Win32_LogicalDiskのサンプルスクリプト>WSH/Win32_LogicalDiskのサンプルスクリプト]]
-[[Win32_Processorのサンプルスクリプト>WSH/Win32_Processorのサンプルスクリプト]]
-[[Win32_NetworkAdapterConfigurationのサンプルスクリプト>WSH/Win32_NetworkAdapterConfigurationのサンプルスクリプト]]
-[[Win32_DiskDriveのサンプルスクリプト>WSH/Win32_DiskDriveのサンプルスクリプト]]

* Win32_ComputerSystemProductを使ったサンプルスクリプト [#z55bb6d9]
#ref(comsyspro.vbs)
以下にWin32_ComputerSystemProductを使用したサンプルスクリプトを記します。~
本サンプルスクリプトでは、以下の4つの値を表示しています。
-プロダクト名
-プロダクトのバージョン
-製品ID
-ベンダー

** サンプルスクリプト [#idd4d09c]
#ref(comsyspro.vbs)
 hostname="."	' dotは自機を示す
 ' uid = "username"
 ' pwd = "password"
 Set oLocater = CreateObject("WbemScripting.SWbemLocator")
 Set oService = oLocater.ConnectServer(hostname, "root/cimv2")
 ' Set oService = oLocater.ConnectServer(hostname, "root/cimv2", uid, pwd)	'ユーザ、パスワード設定をする場合
 oService.Security_.ImpersonationLevel = 3	' デフォルト値は3のため省略可能
 
 Set items = oService.ExecQuery("Select * From Win32_ComputerSystemProduct", , 48)
 
 For Each item In items
   WScript.Echo("プロダクト名: " & item.Name)
   WScript.Echo("プロダクトのバージョン: " & item.Version)
   WScript.Echo("製品ID: " & item.IdentifyingNumber)
   WScript.Echo("ベンダー: " & item.Vendor)
 Next
 
 Set item = Nothing
 Set oService = Nothing
 Set oLocater = Nothing

** 実行例 [#h6811510]
cscriptを使用して実行した時の出力です。
 PS C:\Users\sakura\Desktop> cscript .\comsyspro.vbs
 Microsoft (R) Windows Script Host Version 5.8
 Copyright (C) Microsoft Corporation. All rights reserved.
 
 プロダクト名: 3254CTO
 プロダクトのバージョン: ThinkPad Edge E430
 製品ID: MP20G0P
 ベンダー: LENOVO
 PS C:\Users\sakura\Desktop>

以上、Win32_ComputerSystemProductを使ったサンプルスクリプトでした。

#htmlinsertpcsp(win-btm.html,win-sp.html)

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS