|
-
May 15th, 2013, 09:55 AM
#1
Thread Starter
New Member
[Excel] VBA and Registry Windows 7 Pro 64 bit.. a trick I am missing.
I manage a few kiosk style machines, network restricted and with all the protections we can heap on them.. well, they are all autologon, so have a user name and password in the registry. Unders windows XP I had no problem with reading the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon and the sub keys DefaultUserName and Default Password. and then even writing back a new password from my Excel list of machine and accounts.. but I have discovered that even though I read the above key, it seems that the StdRegProv is actually reading HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Winlogon.. and even on the Windows 7 machines, the values in use are in the first location.
The code I am using, right now just to read the values, is:
Const HKEY_LOCAL_MACHINE = &H80000002
Defpwd = "DefaultPassword"
Defname = "DefaultUserName"
On Error Resume Next
For a = 2 To 501
Cells(1, 12) = a
strhostname = Cells(a, 1).Value
Debug.Print strhostname
Call ResolveIP(strhostname)
If strhostname <> "Unreachable" Then
strhostname = Cells(a, 1).Value
Set objReg = GetObject("winmgmts:\\" & strhostname & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, Defpwd, strValue1
Debug.Print strValue1
objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, Defname, strValue2
Debug.Print strValue2
Cells(a, 8).Value = strValue1
Cells(a, 9).Value = strValue2
strValue1 = ""
strValue2 = ""
Else: Cells(a, 8) = "Unreachable"
End If
Next a
It actually specifies the correct location, but in Windows 7 it defaults to the second location. I am reasonably sure of this as I have gone in with Regedit and applied the settings to the WOW6432Node location and then this existing script "finds" the values. But changing the password in the Wow6432Node location does not get the password applied to the location that is read out in the autologon operation.
Anyone have any idea on how to get it to read out the right set of keys?
I have tried a lot of code pieces I have found on the internet, and so far they don't get me where I need to be.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|