|
This
script enumerates all the Windows profiles on a computer and then lists all the
MAPI profiles for each user too. If
a computer is turned on and no firewall is getting in the way and the Remote
Registry service is running, you can access any key/value on the computer
remotely. Option
Explicit ' ' cscript
//nologo enumerate-profiles.vbs [optional-computer-name] ' Const
HKEY_USERS = &H80000003 Dim
objRegistry, iRC Dim
arrSubKeys, strKey Dim
strProfiles, strProfile, arrProfiles Dim
objWS, strNode On
Error Resume Next If
WScript.Arguments.Count > 0 Then strNode
= WScript.Arguments (0) Else strNode
= "." End
If wscript.Echo
"Checking for profiles on computer " & strNode Set
objWS = CreateObject ("WScript.Shell") Set
objRegistry = GetObject
("winmgmts:{impersonationLevel=impersonate}!\\" & _ strNode
& "/root/default:StdRegProv") If
Err.Number <> 0 Then wscript.Echo
"Error binding to StdRegProv for " & strNode & _ ",
" & Err.Description & " (0x" & Hex(Err.Number) &
")" wscript.quit
1 End
If iRC
= objRegistry.EnumKey (HKEY_USERS, "", arrSubKeys) For
Each strKey In arrSubKeys If
Len (strKey) > 20 Then '
20 is rather arbitrary, but it worked in my testing If
Right (strKey, 8) <> "_Classes" Then wscript.echo
"User: " & strkey Call
TranslateSID (strKey) strProfiles
= "Software\Microsoft\Windows NT\CurrentVersion\" & _ "Windows
Messaging Subsystem\Profiles" strProfiles
= strKey & "\" & strProfiles iRC
= objRegistry.EnumKey (HKEY_USERS, strProfiles, arrProfiles) If
iRC = 0 Then For
each strProfile in arrProfiles wscript.echo
vbTab & vbTab & strProfile Next Else WScript.echo
vbTab & vbTab & "(no profiles for user)" End
If Set
arrProfiles = Nothing End
If End
If Next Set
objWS = Nothing Set
objRegistry = Nothing WScript.Echo
"Done!" WScript.Quit
0 Sub
TranslateSID (strSID) Dim
str str
= GetUserfromSID (strSID) If
Len (str) < 2 Then str = "(unknown name)" wscript.echo
" " & str End
Sub Function
GetUserFromSID (SID) '
from
http://www.windowsitpro.com/WindowsScripting/Article/ArticleID/47127/47127.html Dim
WMISID, Result On
Error Resume Next Set
WMISID = GetObject("winmgmts:{impersonationlevel=impersonate}!" _ &
"/root/cimv2:Win32_SID.SID='" & SID & "'") If
Err = 0 Then Result
= WMISID.ReferencedDomainName & "\" & WMISID.AccountName Else Result
= "" End
If Set
WMSSID = Nothing GetUserFromSID
= Result End
Function From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Tom Kern The 2nd script reads a value from HKCU\Software and writes
it to file I need to read a value from it but I can only access it when
the current user is logged on. I don't know how else to gain access to that key since i
don't know the user's sid, so i put it into a user logon script via GPO so i
can read it when the user logs on and that key is loaded. should i run scripts sycncronously to get this key or is
there a way to read it without the user logged on? thanks On 12/7/05, Jeff Salisbury
<[EMAIL PROTECTED]> wrote: We
had this happen by accident for a short time. The old logon script specied in
the user account properties was running as well as the desired logon script,
which we tie to AD Sites. Both were running, and if I remember right the drive
mappings in the legacy script were winning - which would mean that it was
running after the script that was triggered by group policy. I don't think
there is any harm provided there aren't conflicting drive mappings or other
settings where script timing would need to be verified and accounted for. Jeff
Confidential |
- RE: [ActiveDir] logon scripts Michael B. Smith
- RE: [ActiveDir] logon scripts Rich Milburn
- RE: [ActiveDir] logon scripts Hann, John F.
