Создание и удаление ключей реестра
Создание:
Option Explicit On Error Resume Next Dim strKeyPath Dim strComputer Dim objReg Dim subKey Dim arrSubKeys Dim ParentKey Const HKCR = &H80000000 Const HKCU = &H80000001 Const HKLM = &H80000002 Const HKU = &H80000003 Const HKCC = &H80000005 ParentKey = "SOFTWARE\EdWilson" strKeyPath = "SOFTWARE\EdWilson\VBScriptBook" strComputer = "." Set objReg=GetObject("winmgmts:\\" &_ strComputer & "\root\default:StdRegProv") objReg.CreateKey HKLM, strKeyPath WScript.Echo("Created key :" & strKeyPath) WScript.Echo("New subkey under : " & ParentKey) objReg.EnumKey HKLM, ParentKey, arrSubKeys For Each subKey In arrSubKeys WScript.Echo vbTab & subKey Next
Удаление:
Option Explicit On Error Resume Next Dim strKeyPath Dim strComputer Dim objReg Dim subKey Dim arrSubKeys Dim ParentKey Const HKCR = &H80000000 'HKEY_CLASSES_ROOT Const HKCU = &H80000001 'HKEY_CURRENT_USER Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE Const HKU = &H80000003 'HKEY_USERS Const HKCC = &H80000005 'HKEY_CURRENT_CONFIG ParentKey = "SOFTWARE\EdWilson" strKeyPath = "SOFTWARE\EdWilson\VbscriptBook" strComputer = "." Set objReg=GetObject("winmgmts:\\" &_ strComputer & "\root\default:StdRegProv") objReg.DeleteKey HKLM, strKeyPath objReg.DeleteKey HKLM, ParentKey If Err.Number = 0 Then WScript.Echo("Deleted key:" & strKeyPath) WScript.Echo("Deleted subKey: " & ParentKey) Else WScript.Echo("Error number " & Err.Number & "occurred") End If
Интересное на сайте:
Голосов пока нет
Оставить комментарий