How to check for registry value using VbScript

前端 未结 5 1724
我寻月下人不归
我寻月下人不归 2020-12-30 06:15

How can I check for registry value using VbScript?

相关标签:
5条回答
  • 2020-12-30 06:30

    Try this. This script gets current logged in user's name & home directory:

    On Error Resume Next
    
    Dim objShell, strTemp
    Set objShell = WScript.CreateObject("WScript.Shell")
    
    strTemp = "HKEY_CURRENT_USER\Volatile Environment\USERNAME"
    WScript.Echo "Logged in User: " & objShell.RegRead(strTemp) 
    
    strTemp = "HKEY_CURRENT_USER\Volatile Environment\USERPROFILE"
    WScript.Echo "User Home: " & objShell.RegRead(strTemp) 
    
    0 讨论(0)
  • 2020-12-30 06:35

    Try something like this:

    Dim windowsShell
    Dim regValue
    Set windowsShell = CreateObject("WScript.Shell")
    regValue = windowsShell.RegRead("someRegKey")
    
    0 讨论(0)
  • 2020-12-30 06:37

    This should work for you:

    Dim oShell
    Dim iValue
    
    Set oShell = CreateObject("WScript.Shell")
    
    iValue = oShell.RegRead("HKLM\SOFTWARE\SOMETHINGSOMETHING")
    
    0 讨论(0)
  • 2020-12-30 06:39
       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
    

    Usage :

    str = readfromRegistry("HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\ESD\Install_Dir", "ha")
    wscript.echo "returned " & str
    

    Original post

    0 讨论(0)
  • 2020-12-30 06:54
    Set objShell = WScript.CreateObject("WScript.Shell") 
    skey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{9A25302D-30C0-39D9-BD6F-21E6EC160475}\"
    with CreateObject("WScript.Shell")
        on error resume next            ' turn off error trapping
        sValue = .regread(sKey)       ' read attempt
        bFound = (err.number = 0)     ' test for success
    end with
    if bFound then
        msgbox "exists"
    else
      msgbox "not exists" 
    End If
    
    0 讨论(0)
提交回复
热议问题