Scripted registry access in 64-bit OS
I'm currently running Windows 7 x64, and whenever I use a KScript via direct action or launching a .vbs dependency file to read or write to the registry, it's accessing the 32-bit registry hive.
For example, when I write a value to HKLM\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags, it's actually writing to:
HKLM\Software\WOW6432Node\Microsoft\Windows NT\CurrentVersion\AppCompatFlags, I suppose because it's coming from a 32-bit app, or system account, or something.
When I launch the same script as a local admin, it properly accesses the 64-bit hive at the location specified.
Any thoughts, or suggestions for being able to access the proper registry location?
For example, when I write a value to HKLM\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags, it's actually writing to:
HKLM\Software\WOW6432Node\Microsoft\Windows NT\CurrentVersion\AppCompatFlags, I suppose because it's coming from a 32-bit app, or system account, or something.
When I launch the same script as a local admin, it properly accesses the 64-bit hive at the location specified.
Any thoughts, or suggestions for being able to access the proper registry location?
0 Comments
[ + ] Show comments
Answers (9)
Please log in to answer
Posted by:
dtuttle
15 years ago
Posted by:
mich3ael
14 years ago
Sorry for dropping that question and then staying away so long.
I figured out a workaround that I've been using since... including the 64-bit version of wscript.exe as a dependency with any scripts that need access to the 64-bit registry hive. Since the KBOX agent is a 32-bit app, all the defaults are set to 32-bit hives, and any scripts are launched with the 32-bit version of wscript.exe. So by including and forcing execution with the 64-bit wscript.exe, I have direct access to the 64-bit registry hive without having to significantly change my scripts or execution commands (except changing KBOX_SYS_DIR to KACE_DEPENDENCY_DIR when I specify where to launch wscript.exe from).
I figured out a workaround that I've been using since... including the 64-bit version of wscript.exe as a dependency with any scripts that need access to the 64-bit registry hive. Since the KBOX agent is a 32-bit app, all the defaults are set to 32-bit hives, and any scripts are launched with the 32-bit version of wscript.exe. So by including and forcing execution with the 64-bit wscript.exe, I have direct access to the 64-bit registry hive without having to significantly change my scripts or execution commands (except changing KBOX_SYS_DIR to KACE_DEPENDENCY_DIR when I specify where to launch wscript.exe from).
Posted by:
cblake
15 years ago
Posted by:
jkatkace
15 years ago
Posted by:
dtuttle
15 years ago
Posted by:
GillySpy
15 years ago
To support what Dale said here's a sample command line to update 64-bit keys
c:\windows\system32\cmd.exe /c regedit.exe /s ourfile.reg
Even if we know about issues however we would like to hear from affected customers -- your ticket will either report a new bug or register a vote against an existing bug which helps it get visibility within engineering.
c:\windows\system32\cmd.exe /c regedit.exe /s ourfile.reg
Even if we know about issues however we would like to hear from affected customers -- your ticket will either report a new bug or register a vote against an existing bug which helps it get visibility within engineering.
Posted by:
scottlutz
13 years ago
Since there hasn't been any activity on this post for a while, and since I came across the same issue when trying to query a 64-bit registry, I thought I would share my findings.
From this page:
http://msdn.microsoft.com/en-us/library/aa393067%28v=vs.85%29.aspx
I was able to craft a vbscript that queries both 32 and 64 bit registries, depending on the target platform.
HTH,
Scott
From this page:
http://msdn.microsoft.com/en-us/library/aa393067%28v=vs.85%29.aspx
I was able to craft a vbscript that queries both 32 and 64 bit registries, depending on the target platform.
HTH,
Scott
Posted by:
snissen
13 years ago
I'm an experienced Windows 7 and XP packager who has not worked with 64-bit Windows until now. When I read this article, I was astounded at the differences for scripters between 32- and 64-bit Windows:
http://csi-windows.com/blog/all/27-csi-news-general/266-scripting-migrating-and-managing-registry-data-in-64-bit-windows
I went on to take this class so I could understand the things I needed to know to work in 64-bit Windows using the KBOX 1000:
http://csi-windows.com/courses/windows64bit
I highly recommend this class as the quickest way to understand the subtle differences in the operating environments. And remember that the KBOX agent, like the SCCM client, is a 32-bit executable! Sande
http://csi-windows.com/blog/all/27-csi-news-general/266-scripting-migrating-and-managing-registry-data-in-64-bit-windows
I went on to take this class so I could understand the things I needed to know to work in 64-bit Windows using the KBOX 1000:
http://csi-windows.com/courses/windows64bit
I highly recommend this class as the quickest way to understand the subtle differences in the operating environments. And remember that the KBOX agent, like the SCCM client, is a 32-bit executable! Sande
Posted by:
sbequette
13 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.