Local User and Group Management with VBScript and ADSI

User management for Windows machines can be complicated and convoluted sometimes. Because pretty much everything I do is to make life easier for me, I decided to write some basic functions that can reliably add, delete, change passwords and simply check to see if a particular user exists.

I had a couple of requirements when writing these functions. All of these functions should have at least some error checking to ensure that the user we create or delete is actually created or deleted and if we encounter an error we don’t want to return a success code. So I coded all that into these functions too so that if everything went as planned when you called the function, the function returns “True”. If you encountered an error the function returns “False”.

I thought about creating another function that would edit all of the available flags for each user but couldn’t think of a way to make it easy and pack it into a simple function. I may dream something up and add it to this list of functions in the near future but if anyone reads this and has something please feel free to submit it!

The collective list of functions is:

CreateUser – Creates a local user.
DeleteUser – Deletes a local user.
ChangePassword – Changes the password to the one specified.
RndPassword – Creates a random strong password of variable length.
UserExists – Checks to see if the local user exists.
CreateGroup – Creates a local group.
DeleteGroup – Deletes a local group.
GroupExists – Checks to see if the local group exists.
AddUserToGroup – Adds a local user to the local group specified.
RemoveUserFromGroup – Removes a local user from the local group specified.


One thought on “Local User and Group Management with VBScript and ADSI

Leave a Comment