Vbs registry operation code (add and delete)

Source: Internet
Author: User

1. keywords and values for reading the registry:
You can pass the complete keyword path to the regread method of the wshshell object. For example: CopyCode The 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:Copy codeThe 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 HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Run \ JJ key value is changed to hello. However, note that this key value must exist in advance.
This method is also used to create a new keyword.Copy codeThe 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
Use the regdelete method to pass the complete path to regdelete.
For example
Val = ws. regdel (PATH)
Note: If you want to delete the keyword value, you must 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 perspective, it may be better to use the WMI registry processing function.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.