Disable\Enable user groups from Command line or Api

I am looking for a way to programtically disable and enable different windows user groups using visual basic 6. The purpose of this object is to disable any potential users during nightly jobs and then enable them after completion.

Does anyone know of any console commands I can send or API's I can use to accomplish this?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can't disable a group, but you can disable a user.
An example for disable a user with a .vbs :

Set ObjUser=GetObject("WinNT://MyDomain/MyAccount,user")
objUser.AccountDisabled = True

Good Luck, MG

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SouthDevAuthor Commented:
I am currently trying to implement this method but I get a "General Access Denied Error" upon reaching the set info command.

Public Function Execute(ByVal pstrGroup As String, _
                        ByVal pblnUseDomain As Boolean, _
                        ByVal pblnActive As Boolean) As Long

'*** Strings
    Dim strComputerName As String
    Dim strUserName As String
    Dim strDomainName As String
    '*** Booleans
    Dim blnDisableAccount As Boolean
    '*** Objects
    Dim objWshNet As Object
    Dim oDomain
    Dim User, Member
    '*** Arrays
    Dim arrGroups() As String
    '*** Integers
    Dim i As Integer
    On Error GoTo ExitLogic
    Set objWshNet = CreateObject("WScript.Network")
    strComputerName = objWshNet.ComputerName
    strUserName = objWshNet.UserName
    strDomainName = objWshNet.UserDomain
    blnDisableAccount = Not (pblnActive)
    arrGroups = Split(pstrGroup, ",")
    ' loop through provided groups as long as groups are valid for the parameters provided
    For i = 0 To UBound(arrGroups)
            If Not pblnUseDomain Then
                 Set oDomain = GetObject("WinNT://" & strComputerName & "/" & arrGroups(i))
                  Set oDomain = GetObject("WinNT://" & strDomainName & "/" & arrGroups(i))
            End If
            For Each Member In oDomain.members
               If Member.Class = "User" Then
                     If Not pblnUseDomain Then
                          Set User = GetObject("WinNT://" & strComputerName & "/" & Member.Name & ",user")
                          Set User = GetObject("WinNT://" & strDomainName & "/" & Member.Name & ",user")
                     End If
                     User.accountDisabled = blnDisableAccount
                     Set User = Nothing
                End If
     Next i
    '***Set all object references to nothing
    Set objWshNet = Nothing
    Set oDomain = Nothing
    Set User = Nothing
    Set Member = Nothing
    Erase arrGroups
    if err.number <> 0 then
         msgBox err.description, vbCritical, "Error"
    end if
end  function
Access Denied? check your rights, do you have enough rights? please put the next code in a new file called test.vbs and run it with "cscript test.vbs" please replace MyDomain with a valid domain or computer and MyAccount with a valid account:

Set ObjUser=GetObject("WinNT://MyDomain/MyAccount,user")
objUser.AccountDisabled = True
Please check your rights, "Access Denied" is just a problem for not enough rights.
SouthDevAuthor Commented:
Yeah I am able to succefully alter local computer users/groups for which I have access to but the domain  option fails due to rights. Hopefully there are no security rules disable scripting on the network this will eventually be implemnted on.

Thanks for the help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
OS Security

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.