?
Solved

VB Script to unlock locla admn account

Posted on 2009-02-09
6
Medium Priority
?
1,471 Views
Last Modified: 2012-08-13
Is there a way to programmatically unlock the Admin account if it is locked?

Is there a way to configure things so that Admin will not lock?  Is there a way to programmatically configure it this way?


Thanks

Wajhi
0
Comment
Question by:wajhiuddin
  • 2
  • 2
  • 2
6 Comments
 
LVL 14

Accepted Solution

by:
yehudaha earned 2000 total points
ID: 23594646
i think this will do it

put your values in this lines:

strUsername = "user name"
strComputer = "Computer Name"
' ------ SCRIPT CONFIGURATION ------
strUsername = "user name"
strComputer = "Computer Name"
' ------ END CONFIGURATION ---------
 
set objUser = GetObject("WinNT://" & strComputer & "/" & strUsername)
if objUser.IsAccountLocked = True Then
   objUser.IsAccountLocked = False
   objUser.SetInfo
   WScript.Echo "Account unlocked"
Else
   WScript.Echo "Account not locked"
end If

Open in new window

0
 
LVL 4

Expert Comment

by:solomonacquah
ID: 23594707
0
 
LVL 4

Expert Comment

by:solomonacquah
ID: 23594796
This should use the local computer account.
Set objNetwork = CreateObject("Wscript.Network")
 
strLocalComputer = objNetwork.ComputerName
 
strComputer = strLocalComputer
 
Set UserObj = GetObject("WinNT://" & strcomputer & "/" & "Administrator")
UserObj.IsAccountLocked = 0
UserObj.SetInfo
 
wscript.echo

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Closing Comment

by:wajhiuddin
ID: 31544727
Great, Thanks  Any way we can add some so it will ask a computer name??
We have several computers and user may screw up the script by adding a computer name??
Also can we  have setup account so it will never unlock

Thanks

Wajhi
0
 
LVL 14

Expert Comment

by:yehudaha
ID: 23594891
script will ask for computer name
' ------ SCRIPT CONFIGURATION ------
strUsername = "user name"
strComputer = inputbox("enter Computer Name")
' ------ END CONFIGURATION ---------
 
set objUser = GetObject("WinNT://" & strComputer & "/" & strUsername)
if objUser.IsAccountLocked = True Then
   objUser.IsAccountLocked = False
   objUser.SetInfo
   WScript.Echo "Account unlocked"
Else
   WScript.Echo "Account not locked"
end If

Open in new window

0
 

Author Comment

by:wajhiuddin
ID: 23600617
Thanks This works . If I can get the script to get account never locks this will be great


0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month16 days, 11 hours left to enroll

864 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