Newsgroups: microsoft.public.scripting.vbscript
From: "Torgeir Bakken (MVP)" <Torgeir.Bakken-s...@hydro.com>
Date: Tue, 27 Jan 2004 23:21:44 +0100
Local: Tues, Jan 27 2004 5:21 pm
Subject: Re: Stepping through all users
Jens Lenge wrote: Especially the NT4 prerequisite makes it a bit difficult, because WMI and ADSI > I need my VBScript to perform certain actions for each user that exists on a > given Windows system individually: Create/delete some registry keys into the > respective user's registry branch, and write some files to his/her profile > path (if it already exists, that is if the respective user has ever been > logged in). > What is the best way to identify which users exist on the system, step is out (unless WMI Core/DSClient is installed). To start with, if a user doesn't have a profile path, he/she will not have a To be able to edit an other user's registry hive (HKEY_CURRENT_USER for that For WinXP and Win2k3, reg.exe comes installed with the OS. Reg.exe for Win2k is in the Support Tools found on the Win2k CD, http://www.microsoft.com/windows2000/downloads/servicepacks/sp4/suppo... I think the Win2k version of reg.exe works fine for NT4 as well. To get a list of users and their individual path to each users profile path (and To do this without WMI, you can e.g. use reg.exe to export that key and it's More about RegObj.dll here: Alternatively, do it the easy way. Enumerate all the folders under the > I would also like to identify the "default" user, the "all users" branch, For Win2k and up, see the values AllUsersProfile under HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList > and the original "Administrator" account. That is the account that has -500 as the last characters of it's user SID. Could e.g. be parsed out from the list under the ProfileList. > The script is intended to run on Run this WMI script in a command prompt using cscript.exe, it will list all > Windows NT4, 2000, XP, and 2003. users defined on the computer, and it's user profile path if one exists, as well as identifying the administrator account: ' Retrieve local computer name. ' If you want to run it against a remote computer, use this instead Const HKLM = &H80000002 Set oReg = GetObject("WinMgmts:{impersonationLevel=impersonate}!//" _ Set oWMI = GetObject("WinMgmts:{impersonationLevel=impersonate}!//" _ Set colItems = oWMI.ExecQuery _ For Each oItem In colItems If IsNull(sProfilePath) Then > I applicable, it should also run on Windows Default, ME will only use one profile, but it can be configured to use different > ME (although I am not sure if ME supports different user profiles at all). profiles for different users. -- You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||