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 deployment project.
I thought I would do something like this:
Set oShell = CreateObject("Wscript.Shell")
strPath = oShell.RegRead("HKLM\SOFTWARE\Microsoft\ASP.NET\2.0.50727.0\Path")
and then concatenate strPath with "\Temporary ASP.NET Files" and be done with it.
On an x64 system, however, I am getting the value from the WOW6432Node (HKLM\SOFTWARE\Wow6432Node\Microsoft\ASP.NET\2.0.50727.0), which gives me the 32-bit framework path (C:\Windows\Microsoft.NET\Framework\v2.0.50727), but on an x64 system, I actually want the 64-bit path, i.e. C:\Windows\Microsoft.NET\Framework64\v2.0.50727.
I understand that this happens because the .vbs file is run using the 32-bit script host due to the parent process (the installer) being 32-bit itself.
How can I run the script using the 64-bit script host - or - how can I read the 64-bit values even if the script is run using the 32-bit script host?
Please Check this:
Set oShell = CreateObject("Wscript.Shell") strPath = oShell.RegRead("HKLM64\SOFTWARE\Microsoft\ASP.NET\2.0.50727.0\Path")
https://www.autoitscript.com/autoit3/docs/functions/RegRead.htm
Using Microsoft's documented approache, 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.
I think something like this, but I haven't sorted out how to process the output values.
Not sure about launching the 64-bit script host version, but you should be able to access the 64-bit registry from the 32-bit script host using the WMI
StdRegProv
class, like this:NB: I'm under a 32-bit OS right now, so can't verify that this example works. Beware of bugs :-)
See also the Requesting WMI Data on a 64-bit Platform MSDN article for more info on the subject.