Programmatically Create User Groups

By xerocube | November 9, 2007

I have recently come across the need to create user groups on my local machine for a current project. I have researched and come up with a straightforward VBScript file that I can use as my basis for creating many user groups on each fresh testing installation.

The code is as follows:

‘ Create Network Object
Set objNetwork = WScript.CreateObject(“WScript.Network”)

‘Set the desired group name
strGroup = “Test”

‘ Retreive the local machine name.
strComputer = objNetwork.ComputerName

Set colAccounts = GetObject(“WinNT://” & strComputer & “”)
Set objGroup = colAccounts.Create(“group”, strGroup)
objGroup.SetInfo

The above code will create a user group named “Test” when executed from a VBScript file. This code was created through the use of Microsoft TechNet – User Accounts scripting.

This code is provided to you as-is for your knowledge. I accept no liability in your use of this code.

Topics: Code, VBScript | 1 Comment »

One Response to “Programmatically Create User Groups”

vbscript Says:
April 6th, 2008 at 6:10 pm

[…] from a given folder and all subfolders.http://www.databasejournal.com/scripts/article.php/3517231VBScript – Programmatically create user groups.This sample code shows how to programmatically create user account groups within a Windows […]

Comments

Archives

Blogroll

RockinMedia