Get the App
SLTechnology News&Howtos  ›  Development  › 

How to implement Registry Operation by vbs

Shulou Source: shulou.com Published: 2022-06-03 06:53:14 10月19日 Update

Editor to share with you how to achieve the registry operation of vbs, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to understand it!

1. Read the keywords and values of the registry:

You can pass the full path of the keyword to the regread method of the wshshell object. For example:

The copy code is as follows:

Set ws=wscript.createobject ("wscript.shell")

V=ws.regread ("HKEY_LOCAL_MACHINE\ SOFTWARE\ Microsoft\ Windows\ CurrentVersion\ Run\ nwiz")

Wscript.echo v

2. Write the registry

Use the regwrite method of the wshshell object. Example:

The copy code is as follows:

Path= "HKEY_LOCAL_MACHINE\ SOFTWARE\ Microsoft\ Windows\ CurrentVersion\ Run\"

Set ws=wscript.createobject ("wscript.shell")

T=ws.regwrite (path & "jj", "hello")

In this way,

The key value of HKEY_LOCAL_MACHINE\ SOFTWARE\ Microsoft\ Windows\ CurrentVersion\ Run\ jj was changed to hello. Note, however: this key value must exist in advance.

If you want to create a new keyword, use this method as well.

The copy code is as follows:

Path= "HKEY_LOCAL_MACHINE\ SOFTWARE\ Microsoft\ Windows\ CurrentVersion\ run\ sssa2000\ love\"

Set ws=wscript.createobject ("wscript.shell")

Val=ws.regwrite (path, "nenboy")

Val=ws.regread (path)

Wscript.echo val

Delete keywords and values

Using the regdelete method, just pass the complete path to regdelete

For example

Val=ws.regdel (path)

Note that if you want to delete the value of the keyword, be sure to add "\" at the end of the path, if you do not add a slash, the entire keyword will be deleted.

Of course, from the current point of view, it might be better to use WMI's registry processing function.

The above is all the contents of the article "how to operate the registry in vbs". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Code key registry keyword method article path content object not much example keyword function can pass most slash more knowledge industry angle Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Linux Microsoft OPPO Reno NVidia