如何使用VbScript检查注册表值

13 registry vbscript

如何使用VbScript检查注册表值?

fya*_*sar 28

   function readFromRegistry (strRegistryKey, strDefault )
    Dim WSHShell, value

    On Error Resume Next
    Set WSHShell = CreateObject("WScript.Shell")
    value = WSHShell.RegRead( strRegistryKey )

    if err.number <> 0 then
        readFromRegistry= strDefault
    else
        readFromRegistry=value
    end if

    set WSHShell = nothing
end function
Run Code Online (Sandbox Code Playgroud)

用法:

str = readfromRegistry("HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\ESD\Install_Dir", "ha")
wscript.echo "returned " & str
Run Code Online (Sandbox Code Playgroud)

原帖


Jer*_*ron 7

尝试这样的事情:

Dim windowsShell
Dim regValue
Set windowsShell = CreateObject("WScript.Shell")
regValue = windowsShell.RegRead("someRegKey")
Run Code Online (Sandbox Code Playgroud)