How do I read 64-bit Registry values from VBScript running as a an msi post-installation task?

前端 未结 4 1682
庸人自扰
庸人自扰 2020-12-29 14:39

I need to read the location of the Temporary ASP.NET Files folder from VBScript as part of a post-installation task in an installer created using a Visual Studio 2008 deploy

4条回答
  •  死守一世寂寞
    2020-12-29 15:19

    Using Microsoft's documented approach, Helen's answer is absolutely correct.

    However according to my own tests it turns out that it is enough to specify the __ProviderArchitecture context flag only at the time the connection to the StdRegProv provider is established.
    This makes things much simpler as only setting up the provider needs to be encapsulated in a separate function, otherwise one can use the regular API.

    set reg64 = MakeRegLocator(64)
    reg64.GetStringValue , "SOFTWARE\Microsoft\ASP.NET\2.0.50727.0", "Path", path
    
    WScript.Echo path
    
    ' Establish a connection to the local 32 or 64 bit registry hive as requested.
    ' Parameters:
    '   RegType - The registry bitness: 32 or 64.
    function MakeRegLocator(bitness)
        set ctx = CreateObject("WbemScripting.SWbemNamedValueSet")
        ctx.Add "__ProviderArchitecture", bitness
    
        set locator = CreateObject("Wbemscripting.SWbemLocator")
        set services = locator.ConnectServer("", "root\default", "", "", , , , ctx)
        set reg = services.Get("StdRegProv")
    
        set MakeRegLocator = reg
    end function
    

提交回复
热议问题