Listing 1: Script to Run API Calls Option Explicit ' ------------------------------------------------ ' LAN Manager API Declarations ' ------------------------------------------------ Private Type GROUP_INFO_0 grpi0_name As Long 'LPWSTR in SDK End Type Private Type LOCALGROUP_INFO_0 lgrpi0_name As Long 'LPWSTR in SDK End Type Private Declare Function NetGroupSetInfo Lib "netapi32.dll" ( _ ServerName As Any, GroupName As Any, ByVal Level As Long, _ ByVal pBuf As Long, ByVal pParm_err As Long) As Long Private Declare Function NetLocalGroupSetInfo Lib "netapi32.dll" ( _ ServerName As Any, GroupName As Any, ByVal Level As Long, _ ByVal pBuf As Long, ByVal pParm_err As Long) As Long ' -------------------------------------------------- ' GroupRename - Rename an NT group (global or local) ' -------------------------------------------------- Private Function GroupRename(strServerName As String, _ strGroupName As String, strNewGroupName As String, _ bGlobalGroup As Boolean) As Long Dim ServerName() As Byte Dim GroupName() As Byte Dim NewGroupName() As Byte Dim GlobalGroupInfo As GROUP_INFO_0 Dim LocalGroupInfo As LOCALGROUP_INFO_0 Dim Level As Long Dim lmRetcode As Long ' ' Convert VB strings to Unicode strings ' ServerName = strServerName & vbNullChar GroupName = strGroupName & vbNullChar NewGroupName = strNewGroupName & vbNullChar ' ' Call LAN Manager API Level = 0 If bGlobalGroup Then GlobalGroupInfo.grpi0_name = StrPtr(NewGroupName) lmRetcode = NetGroupSetInfo(ServerName(0), GroupName(0), _ Level, VarPtr(GlobalGroupInfo), 0) Else LocalGroupInfo.lgrpi0_name = StrPtr(NewGroupName) lmRetcode = NetLocalGroupSetInfo(ServerName(0), GroupName(0), _ Level, VarPtr(LocalGroupInfo), 0) End If ' 0 indicates successful operation (NERR_Success) GroupRename = lmRetcode End Function ' ' -------------------------------------------------- Private Sub Command1_Click() Dim ServerName As String Dim GroupName As String Dim NewGroupName As String Dim bGlobalGroup As Boolean Dim retcode As Long ServerName = "\\W_MAISONSL_NT" ' <-- Your PDC name for global group ' or ' NT machine or blank for local machine GroupName = "testgrp" ' <-- Existing group NewGroupName = "testgrp2" ' <-- New group name bGlobalGroup = False ' <-- True for global group (PDC) or 'false for local group. retcode = GroupRename(ServerName, GroupName, NewGroupName, _ bGlobalGroup) If retcode = 0 Then MsgBox "Group renaming operation successfull !" Else MsgBox "Group renaming operation failed. (LMError = " & retcode & ")" End If End Sub