コメント |
@DIV
Set Shell = CreateObject("Shell.Application")
if WScript.Arguments.Count = 0 then
Shell.ShellExecute "cmd.exe", "/c Cscript.exe """ & Wscript.ScriptFullName & """ dummy & pause", "", "runas", 1
Wscript.Quit
end if
Dim obj
' **********************************************************
' インスタンス作成
' **********************************************************
Set obj = new Wmireg
' **********************************************************
' デフォルトメソッド実行
' **********************************************************
Set list = obj(WMI_HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Run")
' **********************************************************
' 一覧表示
' **********************************************************
For Each data in list.Keys
Wscript.Echo data & " : " & list(data)
Next
Wscript.Echo
' **********************************************************
' サブキーの配列を取得
' **********************************************************
Call obj.GetLSubKeyArray(WMI_HKEY_LOCAL_MACHINE, "SOFTWARE\ODBC\ODBCINST.INI")
' **********************************************************
' 一覧表示
' **********************************************************
For Each data in obj.objArray
Wscript.Echo data
Next
const WMI_HKEY_CLASSES_ROOT = &H80000000
const WMI_HKEY_CURRENT_USER = &H80000001
const WMI_HKEY_LOCAL_MACHINE = &H80000002
const WMI_HKEY_USERS = &H80000003
const WMI_HKEY_CURRENT_CONFIG = &H80000005
const WMI_REG_SZ = 1
const WMI_REG_EXPAND_SZ = 2
const WMI_REG_BINARY = 3
const WMI_REG_DWORD = 4
const WMI_REG_MULTI_SZ = 7
Class Wmireg
Public objReg
Public objArray
' ************************************************
' Initialize イベント
' ************************************************
Private Sub Class_Initialize
Set objReg = _
GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
".\root\default:StdRegProv")
End Sub
' ************************************************
' サブキーの配列を取得
' ************************************************
Public Function GetLSubKeyArray( defKey, strPath )
Dim aSubKeys,str
objReg.EnumKey defKey, strPath, objArray
end function
' ************************************************
' 値の一覧の連想配列を取得( 規定のメソッド )
' ************************************************
Public Default Function GetLValueArray( defKey, strPath )
Dim aValueNames, aValueTypes, strValue, aValue
Set var = CreateObject( "Scripting.Dictionary" )
objReg.EnumValues defKey, strPath,_
aValueNames, aValueTypes
For i=0 To UBound(aValueNames)
Select Case aValueTypes(i)
Case WMI_REG_SZ
objReg.GetStringValue _
defKey,strPath,aValueNames(i),strValue
var(aValueNames(i)) = strValue
Case WMI_REG_EXPAND_SZ
objReg.GetExpandedStringValue _
defKey,strPath,aValueNames(i),strValue
var(aValueNames(i)) = strValue
Case WMI_REG_DWORD
objReg.GetDWORDValue _
defKey,strPath,aValueNames(i),strValue
var(aValueNames(i)) = strValue
Case WMI_REG_MULTI_SZ
objReg.GetMultiStringValue _
defKey,strPath,aValueNames(i),aValue
var(aValueNames(i)) = aValue
Case WMI_REG_BINARY
objReg.GetBinaryValue _
defKey,strPath,aValueNames(i),aValue
var(aValueNames(i)) = aValue
End Select
Next
Set GetLValueArray = var
end function
' ************************************************
' 文字列セット
' ************************************************
Public Function SetLString( defKey, strPath, strName, strValue )
objReg.SetStringValue _
defKey,strPath,strName,strValue
end function
' ************************************************
' 整数セット
' ************************************************
Public Function SetLDword( defKey, strPath, strName, dwValue )
objReg.SetDWORDValue _
defKey,strPath,strName,dwValue
end function
End Class
@END |