SHARE
Facebook X Pinterest WhatsApp

User/Group Administration: Script to Unlock a User Account

Author: Rod TrentPlatform: Windows NT with WSH 2.0 WMI 1.1, Windows 2000Type: WSH, VBScript AcctUnlock prompts for a username and domain name and unlocks the user account. The script will let you know if the account unlock was successful. Save as a .VBS file and run with either CScript or WScript. Scroll down to view […]

Sep 25, 2003
Datamation content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Author: Rod Trent
Platform: Windows NT with WSH 2.0 WMI 1.1, Windows 2000
Type: WSH, VBScript

AcctUnlock prompts for a username and domain name and unlocks the user account. The script will let you know if the account unlock was successful. Save as a .VBS file and run with either CScript or WScript.

Scroll down to view the script.


UserName = InputBox("Enter the user's login name that you want to unlock:")

DomainName = InputBox("Enter the domain name in which the user account exists:")

Set UserObj = GetObject("WinNT://"& DomainName &"/"& UserName &"")
If UserObj.IsAccountLocked = -1 then UserObj.IsAccountLocked = 0
UserObj.SetInfo

If err.number = 0 Then
Wscript.Echo "The Account Unlock Failed.  Check that the account is, in fact, locked-out."
Else
Wscript.Echo "The Account Unlock was Successful"
End if

Disclaimer: We hope that the information in these pages is valuable to you. Your use of the information contained in these pages, however, is at your sole risk. All information on these pages is provided “as -is”, without any warranty, whether express or implied, of its accuracy, completeness, fitness for a particular purpose, title or non-infringement, and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by me. I shall not be liable for any damages you may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.

  SEE ALL
APPLICATIONS ARTICLES
 

Recommended for you...

How Network Detection & Response (NDR) Works
Sarah Hunt
Oct 1, 2025
Common Data Visualization Examples: Transform Numbers into Narratives
Liz Ticong
Sep 24, 2025
8 Best Data Analytics Tools: Gain Data-Driven Advantage
Datamation Logo

Datamation is the leading industry resource for B2B data professionals and technology buyers. Datamation's focus is on providing insight into the latest trends and innovation in AI, data security, big data, and more, along with in-depth product recommendations and comparisons. More than 1.7M users gain insight and guidance from Datamation every year.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.