locked
WScript RegRead unable to read the registry key RRS feed

  • Question

  • Hi All,

    I am using the Wscript shell to check the registry entry in the VBscript. When i am running the code from console it is working but when i run the same through a custom action from an installer. It is giving below error message:

    Error Message:

    ###Info: -2147024894 ::: Invalid root in registry key "HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.6\InstallPath\". :: WshShell.RegRead

    Script used:

    Function readFromRegistry(strRegistryKey, strDefault)
    Dim WSHShell, value, CheckFor, CmdToRun, returnValue
    On Error Resume Next
    err.Clear
    Set WSHShell = CreateObject("WScript.Shell")
    value = WSHShell.RegRead(strRegistryKey)
    if err.number <> 0 then
    readFromRegistry = strDefault
    else
    readFromRegistry = value
    end if
    MsgBox readFromRegistry
    set WSHShell = Nothing
    End Function
    'call readFromRegistry("HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.6\InstallPath\", "NONE")
    call InstallWebdrivers()
    'call readFromRegistry("HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.6\InstallPath\", "NONE")
    Function InstallWebdrivers()
    Dim strCMD, strRootFolder, strPythonInstallPath, strWebMgrPath, strResult
    strPythonInstallPath = readFromRegistry("HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.6\InstallPath\", "NONE")
    IF strPythonInstallPath = "NONE" Then
    strPythonInstallPath = readFromRegistry("HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.6\InstallPath\", "NONE")
    End IF
    IF strPythonInstallPath = "NONE" Then
    strPythonInstallPath = readFromRegistry("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\3.6\InstallPath\", "NONE")
    End IF
    'MsgBox strPythonInstallPath
    strWebMgrPath = strPythonInstallPath & "\Scripts\webdrivermanager.exe"
    strRootFolder = "C:\"
    strCMD = """" & strWebMgrPath & """" & " --linkpath " & strRootFolder & " chrome firefox"
    Wscript.Echo(strCMD)
    'strResult = RunPowerShellCommand(strCMD)
    End Function



    • Edited by JiteshMalik Monday, November 2, 2020 5:54 PM
    Monday, November 2, 2020 5:53 PM

All replies

  • The installer cannot see the user registry.  YOu cannot use that to set custom entries for a user.

    Please DO NOT post colorized code in technical forums.

    This forum will close in two days.  Ask installer issues in the MS Developers forums.


    \_(ツ)_/

    Tuesday, November 3, 2020 1:04 AM