Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Disable User with VB6

Posted on 2006-10-20
2
Medium Priority
?
149 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

885 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