Get the App
SLTechnology News&Howtos  ›  Development  › 

How the VBS script manipulates the registry using WMI

Shulou Source: shulou.com Published: 2022-06-03 07:45:58 10月25日 Update

This article mainly introduces the VBS script how to use WMI to operate the registry, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

OReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath

OReg.SetExpandedStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

OReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

OReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue

OReg.SetBinaryValue HKEY_LOCAL_MACHINE,strPath,strValueName,uBinary

OReg.SetMultiStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,arrStringValues

OReg.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath

OReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,strStringValueName

OReg.GetExpandedStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

OReg.GetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue

OReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

OReg.GetBinaryValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,uBinary

OReg.GetMultiStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,arrStringValues

'-

Const HKEY_CLASSES_ROOT = & H80000000

Const HKEY_CURRENT_USER = & H80000001

Const HKEY_LOCAL_MACHINE = & H80000002

Const HKEY_USERS = & H80000003

Const HKEY_CURRENT_CONFIG = & H80000005

'create a registry key

Const HKEY_LOCAL_MACHINE = & H80000002

StrComputer = "."

Set StdOut = WScript.StdOut

Set oReg=GetObject ("winmgmts: {impersonationLevel=impersonate}!\" & _

StrComputer & "\ root\ default:StdRegProv")

StrKeyPath = "SOFTWARE\ System Admin Scripting Guide"

OReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath

'create a multistring value

Const HKEY_LOCAL_MACHINE = & H80000002

StrComputer = "."

Set oReg=GetObject ("winmgmts: {impersonationLevel=impersonate}!\" & _

StrComputer & "\ root\ default:StdRegProv")

StrKeyPath = "SOFTWARE\ System Admin Scripting Guide"

StrValueName = "Multi String ValueName"

ArrStringValues = Array ("first string", "second string", _

"third string", "fourth string")

OReg.SetMultiStringValue HKEY_LOCAL_MACHINE,strKeyPath,_

StrValueName,arrStringValues

'create an extended string value

Const HKEY_LOCAL_MACHINE = & H80000002

StrComputer = "."

Set oReg=GetObject ("winmgmts: {impersonationLevel=impersonate}!\" & _

StrComputer & "\ root\ default:StdRegProv")

StrKeyPath = "SOFTWARE\ System Admin Scripting Guide"

StrValueName = "Expanded String ValueName"

StrValue = "% PATHEXT%"

OReg.SetExpandedStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

'create a string and DWORD value

Const HKEY_LOCAL_MACHINE = & H80000002

StrComputer = "."

Set StdOut = WScript.StdOut

Set oReg=GetObject ("winmgmts: {impersonationLevel=impersonate}!\" & _

StrComputer & "\ root\ default:StdRegProv")

StrKeyPath = "SOFTWARE\ System Admin Scripting Guide"

StrValueName = "String ValueName"

StrValue = "string value"

OReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

StrValueName = "DWORD ValueName"

DwValue = 82

OReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue

'Delete the registry key

Const HKEY_LOCAL_MACHINE = & H80000002

StrComputer = "."

Set oReg=GetObject ("winmgmts: {impersonationLevel=impersonate}!\" & _

StrComputer & "\ root\ default:StdRegProv")

StrKeyPath = "SOFTWARE\ System Admin Scripting Guide"

OReg.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath

'delete the registry value

Const HKEY_LOCAL_MACHINE = & H80000002

StrComputer = "."

Set oReg=GetObject ("winmgmts: {impersonationLevel=impersonate}!\" & _

StrComputer & "\ root\ default:StdRegProv")

StrKeyPath = "SOFTWARE\ System Admin Scripting Guide"

StrDWORDValueName = "DWORDValueName"

StrExpandedStringValueName = "ExpandedStringValueName"

StrMultiStringValueName = "MultiStringValueName"

StrStringValueName = "StringValueName"

OReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,strDWORDValueName

OReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,strExpandedStringValueName

OReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,strMultiStringValueName

OReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,strStringValueName

'enumerate registry values and types

'enumerate child items

'list registry files

'Monitor registry subkey events

'Monitor registry subtree events

'read the binary registry value

Const HKEY_LOCAL_MACHINE = & H80000002

StrComputer = "."

Set StdOut = WScript.StdOut

Set oReg=GetObject ("winmgmts: {impersonationLevel=impersonate}!\" & _

StrComputer & "\ root\ default:StdRegProv")

StrKeyPath = "SOFTWARE\ Microsoft\ Windows NT\ CurrentVersion"

StrValueName = "LicenseInfo"

OReg.GetBinaryValue HKEY_LOCAL_MACHINE,strKeyPath,_

StrValueName,strValue

For I = lBound (strValue) to uBound (strValue)

StdOut.WriteLine strValue (I)

Next

Thank you for reading this article carefully. I hope the article "how to use VBS script to operate the registry with WMI" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Registry articles characters strings scripts events subkeys monitoring binaries values interests at the same time files more friends knowledge types ribbons industries information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Shulou Information Microsoft Linux Shulou Tech Info