Solved

Disable User with VB6

Posted on 2006-10-20
2
144 Views
Last Modified: 2010-04-30
How can I have VB enable/disable a user, the same way I would manually do it through "Control Panel/Administrative Tools/Computer Management/Local Users and Groups/Users" and right-click to open the "Properties" window and check/uncheck the "Account is Disable" checkbox?

Thanks,
Mike
0
Comment
Question by:CCIG2006
2 Comments
 
LVL 28

Expert Comment

by:Ark
ID: 17782633
0
 
LVL 6

Accepted Solution

by:
tone28 earned 500 total points
ID: 17785360
Here is a quick example of one way you could do it.

Private Sub Command1_Click()
    Dim t As Object
    Dim strComputer As String
    strComputer = "."
    On Error GoTo HandleError
    Set t = GetObject("WinNT://" & strComputer & "/" & Text1.Text)
    MsgBox t.AccountDisabled
    t.AccountDisabled = True
    t.SetInfo
    MsgBox t.AccountDisabled
    Exit Sub
HandleError:
    MsgBox Err.Description
End Sub
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question