VBS script uses WMI to manipulate the registry code 1th/2 page _vbs

Source: Internet
Author: User

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 multiple string values
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 Value Name"
Arrstringvalues = Array ("A-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 Value Name"
strvalue = "%pathext%"
Oreg.setexpandedstringvalue Hkey_local_machine,strkeypath,strvaluename,strvalue

' Create string and DWORD values
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 Value Name"
strvalue = "String Value"
Oreg.setstringvalue Hkey_local_machine,strkeypath,strvaluename,strvalue
strValueName = "DWORD Value Name"
Dwvalue = 82
Oreg.setdwordvalue Hkey_local_machine,strkeypath,strvaluename,dwvalue



' Delete 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 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 = "DWORD Value Name"
Strexpandedstringvaluename = "Expanded String Value Name"
Strmultistringvaluename = "Multi String Value Name"
Strstringvaluename = "String Value Name"
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 subkeys
' List registry files
' Monitoring registry subkey events
' Monitoring registry subtree events
' Read binary registry values

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

Current 1/2 page 12 Next read the full text

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.