레지스트리 키 및 문자열 값 입력/쿼리 VBS (VB Script) Etc.2010. 3. 2. 16:30
' 키 및 문자열 값 입력/업데이트
Set oArgs = WScript.Arguments
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\<Key Name>"
oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
strValueName = "<Sting Value Name>"
strValue = oArgs(0)
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
' 문자열 값 쿼리
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\<Key Name>"
strValueName = "<String Value Name 1>"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue1
strValueName = "<String Value Name 2>"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue2
If IsNull(strValue1) OR IsNull(strValue2) Then
WScript.Quit
End If
WScript.Echo strValue1
WScript.Echo strValue2