Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How the VBS script manipulates the registry using WMI

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report