Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get value from remote registry. 1

Status
Not open for further replies.

rtshort

IS-IT--Management
Feb 28, 2001
878
US
Can someone point me in the right direction to write a script that will read a registry key for all of the machines in an active directory OU. I have the code to go through all of the machines in the OU, just need to be able to get a registry value also.

TIA

Rob
Just my $.02.
 
Thanks for the quick reply. I was going by this article on TechNet, and trying to use HKEY_CURRENT_USER but the link that you gave me says I can't do that.
It seems like it will work from that page, but the Value I get returned is "Null".

What I'm trying to accomplish is see what version of Word is on all of out PC's so I don't have to go to 3 different buildings and 150+ PC's to look. :)


Rob
Just my $.02.
 
I don't know what I'm thinking. I'm using HKEY_CLASSES_ROOT.

Rob
Just my $.02.
 
For anyone who stumbles across this, I never got the HKCR to work. I ended up using:

HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\Winword.exe\path and breaking it down fromt here. (Office 14 = Version 2010, etc.)


Rob
Just my $.02.
 
Remotely, the HKCU can be accessed through HKU\SID. It's sometimes a pain but...
Let say you know jdoe is logged on and you want to read a key in the hive. Start by enumerating HKLM\Software\Microsoft\Windows\CurrentVersion\ProfList and reading the ProfileImagePath value. If the data contains "jdoe" you know the key is the users SID. Use that SID to access the user's hive.

-Geates


"I hope I can chill and see the change - stop the bleed inside and feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
A while ago I wrote something to do the same thing you're looking to do. Maybe you can chop it up to do what you need to do, too.

It is a command-line script, ran like:
C:\> myscript.vbs computername

It gives you the registry value for the location of the HOSTS file.

This is supposed to be just a two line script, but there's word wrap happening on this forum.

Hope this helps.

GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & wscript.arguments.item(0) & "\root\default:StdRegProv").GetExpandedStringValue &H80000002,"SYSTEM\CurrentControlSet\services\Tcpip\Parameters","DataBasePath",strValue
Wscript.Echo "The Windows HOSTS path is: " & strValue
 
Ah yes. You can also do as billbrasky pointed out, use a registry object connected to a remote WMI. Perhaps this site may be of assitance.
[link]http://www.activexperts.com/activmonitor/windowsmanagement/scripts/operatingsystem/registry/[/url]

Code:
const HKCU = &H80000002
set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputerName & "\root\default:StdRegProv")
objReg.GetExpandedStringValue HKCU, "SYSTEM\CurrentControlSet\services\Tcpip\Parameters", "DataBasePath", strValue
Wscript.Echo "The Windows HOSTS path is: " & strValue

-Geates

"I hope I can chill and see the change - stop the bleed inside and feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top