Solved

Disable User with VB6

Posted on 2006-10-20
2
141 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 27

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now