在路径的所有子项中搜索注册表项 [英] Search for registry key in all of the subkeys of a path
问题描述
我想在HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\IDE
下找到关键的设备参数".
I want to find the key "Device Parameters' under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\IDE
.
但是,BD/DVD/CD ROM/Writers
在每个系统中都有不同的密钥.我的当前是 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\IDE\CdRomHL-DT-ST_DVDRAM_GH20NS15________________IL00____\5&15602d3e&0&0.1.0\Device Parameters
.
But, the BD/DVD/CD ROM/Writers
makes a different key in every system. Mine currently is HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\IDE\CdRomHL-DT-ST_DVDRAM_GH20NS15________________IL00____\5&15602d3e&0&0.1.0\Device Parameters
.
但是我想搜索IDE下和BD/DVD/CD ROM/Writers
下的每个子项以获取设备参数.有一个二进制值 DefaultDVDregion
,我想为每个 BD/DVD/CD ROM/Writers
将它设置为 0.
But I want to search every subkey under IDE and under BD/DVD/CD ROM/Writers
to get the device parameters. There is a binary value DefaultDVDregion
and i want to set it to 0 for every BD/DVD/CD ROM/Writers
.
我想在 VBScript 中执行此操作.
I'd like to do this in VBScript.
推荐答案
此代码将遍历 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\IDE
中的所有键,并针对每个键查看内部它打印出DefaultDvdRegion
的DWORD值.
This code will loop through all the keys in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\IDE
and, for each key, look inside it to print out the DWORD value of DefaultDvdRegion
.
Option Explicit
Const HKEY_LOCAL_MACHINE = &H80000002
Dim oReg : Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
Dim oShell : Set oShell = CreateObject("WScript.Shell")
Dim sPath, aSub, sKey, aSubToo, sKeyToo, dwValue
' Get all keys within sPath
sPath = "SYSTEM\CurrentControlSet\Enum\IDE"
oReg.EnumKey HKEY_LOCAL_MACHINE, sPath, aSub
' Loop through each key
For Each sKey In aSub
' Get all subkeys within the key 'sKey'
oReg.EnumKey HKEY_LOCAL_MACHINE, sPath & "\" & sKey, aSubToo
For Each sKeyToo In aSubToo
' Try and get the DWORD value in Device Parameters\DefaultDvdRegion
oReg.GetDWORDValue HKEY_LOCAL_MACHINE, sPath & "\" & sKey & "\" & sKeyToo & "\Device Parameters", "DefaultDvdRegion", dwValue
Wscript.Echo "DVDRegion of " & sPath & "\" & sKey & "\" & sKeyToo & " = " & dwValue
Next
Next
这不是我最好的代码,但应该给你你正在寻找的东西.在我的机器上,我得到以下输出:
It's not my finest code, but should give you what you are looking for. On my machine, I get the following output:
DVDRegion of SYSTEM\CurrentControlSet\Enum\IDE\CdRomOptiarc_DVD_RW_AD-7200S_________________1.0A____\5&3308a5ad&0&1.0.0 = 2
DVDRegion of SYSTEM\CurrentControlSet\Enum\IDE\DiskSAMSUNG_HD103UJ_________________________1AA01113\5&76d4b99&0&0.0.0 =
这是有道理的,因为我的 DVD 驱动器的区域代码为 2(欧洲),而我的硬盘驱动器没有区域代码.
Which makes sense, because my DVD drive has a region code of 2 (Europe) and my hard drive has no region code.
这篇关于在路径的所有子项中搜索注册表项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!