代码之家  ›  专栏  ›  技术社区  ›  opensas

如何用vbscript读取注册表项的所有值?

  •  1
  • opensas  · 技术社区  · 15 年前

    我的注册表中有以下值

    HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Accepted Documents\

    价值观:

    * -> application/msword
    ** -> application/vnd.ms-excel
    *** -> application/vnd.ms-powerpoint
    

    等等

    具有 Wscript.Shell RegRead 我只能读一个值,但我不知道预先的值。。。

    1 回复  |  直到 7 年前
        1
  •  1
  •   Derek Hinchliffe opensas    13 年前

    好吧,我明白了

    我必须使用wmi,如下所示:

    option explicit
    
    const HKLM = &H80000002
    
    dim keyPath
    keyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Accepted Documents"
    
    dim reg
    
    dim valueNames, types
    dim value
    dim i
    
      set reg = getObject( "Winmgmts:root\default:StdRegProv" )
    
      if reg.enumValues( HKLM, keyPath, valueNames, types ) = 0 then
        if isArray( valueNames ) then
          for i = 0 to UBound( valueNames )
            reg.getStringValue HKLM, keyPath, valueNames(i), value
            msgBox( valueNames(i) & "=" & value )
          next
        end if
      end if
    

    sas公司