Ok Here is my script, was posted before but made some changes.

Richard Farthing

code:
 
; Used to hide the command window when complied into an .exe using kixcrypt.exe and kixforms
; Set at the top so that is it the first command used
SETCONSOLE("hide")

; Created by Richard Farthing
; Created on "15th August 2002"
;
; REQUIRES:
; KIXTART 4.10 - Kix32.exe in %windir%\system32
; KIXFORMS BUILD 21 - kixforms.dll in %windir%\system32 and registered with "regsvr32 kixforms.dll"
; An active directory enabled machine

; Version
$VERSION = "V1.1"


; Enable Logging (1 = enabled and 0 = disabled)
$LOGGING = 1

; Name of Program : Key User Scripts
;
; Use of the Program
;
; This program is intened to allow key users (apart of the account operator group)
; It will allow them to do the following
;
; 1) Reset a given users password to the string set in the variable $PASSWORD
;
; 2) Unlock a locked account

BREAK ON ; enables canceling of the script without auto rebooting.
; DEBUG ON ; uncomment this to enable debuging

; SET Variables
$FILE_SERVER = "fileprint"
$PASSWORD = "aa123456"
$NOTAUTHORISED ="\\$FILE_SERVER\keyuser$\notauthorised.csv" ;file 1
$RUNLOG = "\\$FILE_SERVER\keyuser$\runlog.csv" ;file 2
$UNLOCKLOG = "\\$FILE_SERVER\keyuser$\unlocklog.csv" ;file 3
$PASSWORDLOG = "\\$FILE_SERVER\keyuser$\passwordlog.csv" ;file 4

; Authorise the user
$AUTH = CreateObject("Kixtart.Form") ; Create a form called $AUTH
$AUTH.Caption = "Authorising @USERID, Please Wait"
$AUTH.ScaleWidth = 475
$AUTH.ScaleHeight = 75
$AUTH.FontSize = 12
$AUTH.FontName = "Arial"
$AUTH.PrintXY(30,30,"Please Wait......")
$AUTH.Center
$AUTH.show

IF ingroup("Account Operators") = 1

$= $AUTH.MsgBox("You are Authorised to run this program", "Authorised")
$AUTHORISED = "YES"

ELSE
$= $AUTH.MsgBox("You are NOT Authorised to run this program", "NOT Authorised")
$AUTHORISED = "NO"


IF $LOGGING = 1
$NUL=Open(1,$NOTAUTHORISED,5)
$NUL=writeline (1,"@USERID,@DATE,@TIME,$AUTHORISED" + Chr(13) + Chr(10))
$NUL=CLOSE(1)
ENDIF
quit()
endif
$AUTH = 0 ;Close the form called $AUTH

; Runlog
IF $LOGGING = 1
$NUL=Open(2,$RUNLOG,5)
$NUL=writeline (2,"@USERID,@DATE,@TIME,$AUTHORISED" + Chr(13) + Chr(10))
$NUL=CLOSE(2)
ENDIF

; Form Vars
$FORM = CreateObject("Kixtart.Form") ; Create form called $FORM
$FORM.Caption = "Password Reset $VERSION - Written by Richard Farthing"
$FORM.ScaleHeight = 215
$FORM.ScaleWidth = 425
$FORM.FontName = "Arial"
$FORM.FontSize = 9
$FORM.Center

$FRABANNER = $FORM.PictureBox
$FRABANNER.BackColor = $FORM.RGB(255,255,255)
$FRABANNER.Height = 75
$FRABANNER.Left = 8
$FRABANNER.Top = 10
$FRABANNER.Width = 410

$FRADETAILS = $FORM.Frame("Details")
$FRADETAILS.Height = 120
$FRADETAILS.Left = 8
$FRADETAILS.Top = 85
$FRADETAILS.Width = 410

$CMDEXIT = $FRADETAILS.CommandButton("Exit!")
$CMDEXIT.FontSize = 12
$CMDEXIT.Top = 85
$CMDEXIT.Width = 129
$CMDEXIT.Left = 272
$CMDEXIT.HEIGHT = 22
$CMDEXIT.OnClick = "quit()"

$TXTUSERNAME = $FRADETAILS.TextBox
$TXTUSERNAME.Height = 25
$TXTUSERNAME.Left = 104
$TXTUSERNAME.Top = 24
$TXTUSERNAME.Text = ""
$TXTUSERNAME.Width = 161

$CMDFINDUSER = $FRADETAILS.CommandButton("Find User!")
$CMDFINDUSER.Default = 1 ; True
$CMDFINDUSER.FontSize = 12
$CMDFINDUSER.Left = 272
$CMDFINDUSER.Top = 24
$CMDFINDUSER.Width = 129
$CMDFINDUSER.HEIGHT = 22
$CMDFINDUSER.OnClick = "cmdFindUser_Click()"

$LABEL_USERNAME = $FRADETAILS.Label
$LABEL_USERNAME.Caption = "Username:"
$LABEL_USERNAME.Height = $TXTUSERNAME.Height
$LABEL_USERNAME.Width = 75
$LABEL_USERNAME.Left = $TXTUSERNAME.Left - $LABEL_USERNAME.Width
$LABEL_USERNAME.Top = $TXTUSERNAME.Top

$CMDRESET_PASSWORD = $FRADETAILS.CommandButton("Reset Password")
$CMDRESET_PASSWORD.Default = 0 ; True
$CMDRESET_PASSWORD.FontSize = 12
$CMDRESET_PASSWORD.Left = 104
$CMDRESET_PASSWORD.Top = 85
$CMDRESET_PASSWORD.Width = 129
$CMDRESET_PASSWORD.HEIGHT = 22
$CMDRESET_PASSWORD.Enabled = 0 ; Disabled / False
$CMDRESET_PASSWORD.OnClick = "Reset_Password()"

$CMDUNLOCK = $FRADETAILS.CommandButton("Unlock Account")
$CMDUNLOCK.Default = 0 ; True
$CMDUNLOCK.FontSize = 12
$CMDUNLOCK.Left = 104
$CMDUNLOCK.Top = 58
$CMDUNLOCK.Width = 129
$CMDUNLOCK.HEIGHT = 22
$CMDUNLOCK.Enabled = 0 ; Disabled / False
$CMDUNLOCK.OnClick = "Unlock_Account()"


; Draw on the banner
$FRABANNER.FontSize = 16
$FRABANNER.FontSize = 16
$FRABANNER.ForeColor = 1
$FRABANNER.PrintXY(50,7,"Client Server - Password Reset")
$FRABANNER.FontSize = 12
$FRABANNER.FontBold = 1
$FRABANNER.PrintXY(110,35,"Welcome @USERID")
$FRABANNER.FontBold = 0
$FRABANNER.FontSize = 10
$FRABANNER.ForeColor = $FORM.RGB(0,100,100)

DIM $STRUSERNAME
DIM $STRUSERPATH

$FORM.Show
$TXTUSERNAME.SetFocus

WHILE $FORM.Visible
$=Execute($FORM.DoEvents)
LOOP

$FORM = 0 ;Close the form called $FORM

EXIT 1

FUNCTION cmdFindUser_Click()

DIM $WAIT
$WAIT = CreateObject("Kixtart.Form") ; Create form called $WAIT
$WAIT.Caption = "One moment please..."
$WAIT.ScaleWidth = 400
$WAIT.ScaleHeight = 75
$WAIT.FontSize = 12
$WAIT.FontName = "Arial"
$WAIT.PrintXY(30,30,"Searching for User, one moment please...")
$WAIT.Center
DIM $USERACCOUNT,$adsGroup
IF $TXTUSERNAME.Text = ""
$= $FORM.MsgBox("You must specify a username before clicking Find.", "Username invalid")
else
IF $TXTUSERNAME.Text = "administrator"
$= $FORM.MsgBox("You are not allowed to reset this password.", "Username invalid")
else
IF $TXTUSERNAME.Text = "rf.admin"
$= $FORM.MsgBox("You are not allowed to reset this password.", "Username invalid")
else
IF $TXTUSERNAME.Text = "tr.admin"
$= $FORM.MsgBox("You are not allowed to reset this password.", "Username invalid")
$TXTUSERNAME.Text = $STRUSERNAME
EXIT Sub
ELSE
$STRUSERNAME = $TXTUSERNAME.Text
ENDIF
$WAIT.Show
$STRUSERPATH = "WinNT://dcserve1/$STRUSERNAME,User"
$STRUSERPATH2 = "WinNT://dcserve2/$STRUSERNAME,User"
$USERACCOUNT = GetObject($STRUSERPATH)
IF Not $USERACCOUNT
; User does not exist
$= $FORM.MsgBox("A user called (" + $TXTUSERNAME.Text + ") does not exist.", "Username invalid")
ELSE
; User exists so bind to it
$USERACCOUNT.GetInfo
$CMDRESET_PASSWORD.Enabled = 1 ; Enable the reset password button
$CMDFINDUSER.Enabled = 0 ; Disable the finduser button
IF $USERACCOUNT.IsAccountLocked

$CMDUNLOCK.Enabled = 1 ; Enable the unlock button
$CMDRESET_PASSWORD.Enabled = 0 ; disable the reset password button
ENDIF
ENDIF

$FORM.Refresh
$TXTUSERNAME.SetFocus

ENDFUNCTION

FUNCTION Unlock_Account()

$WAIT = CreateObject("Kixtart.Form") ; Create form called $WAIT
$WAIT.Caption = "One moment please..."
$WAIT.ScaleWidth = 400
$WAIT.ScaleHeight = 75
$WAIT.FontSize = 12
$WAIT.FontName = "Arial"
$WAIT.PrintXY(30,30,"Unlocking Account, one moment please...")
$WAIT.Center
$WAIT.Show
DIM $USERACCOUNT
; APPEND to $UNLOCKLOG
IF $LOGGING = 1
$USERNAME = $TXTUSERNAME.Text
$NUL=Open(3,$UNLOCKLOG,5)
$NUL=writeline (3,"@USERID,$USERNAME,@DATE,@TIME" + Chr(13) + Chr(10))
$NUL=CLOSE(3)
ENDIF
; Unlock the account
$USERACCOUNT = GetObject($STRUSERPATH)
$USERACCOUNT.GetInfo
$USERACCOUNT.IsAccountLocked = 0
$USERACCOUNT.SetInfo
$= $FORM.MsgBox("The user (" + $STRUSERNAME + ") has been unlocked.", "User enabled")
$WAIT = 0 ; close the form called $WAIT
$USERACCOUNT = 0
$FORM.Refresh
$CMDEXIT.SetFocus
$CMDUNLOCK.Enabled = 0 ; Disable the unlock button
reset_password()

ENDFUNCTION

FUNCTION Reset_Password()

$WAIT = CreateObject("Kixtart.Form") ; Create form called $WAIT
$WAIT.Caption = "One moment please..."
$WAIT.ScaleWidth = 400
$WAIT.ScaleHeight = 75
$WAIT.FontSize = 12
$WAIT.FontName = "Arial"
$WAIT.PrintXY(30,30,"Resetting Password, one moment please...")
$WAIT.Center
$WAIT.Show
DIM $USERACCOUNT
; APPEND to $PASSWORDLOG
IF $LOGGING = 1
$USERNAME = $TXTUSERNAME.Text
$NUL=Open(4,$PASSWORDLOG,5)
$NUL=writeline (4,"@USERID,$USERNAME,@DATE,@TIME" + Chr(13) + Chr(10))
$NUL=CLOSE(4)
ENDIF
; Reset the pasword on the account
$USERACCOUNT = GetObject($STRUSERPATH)
$USERACCOUNT.GetInfo
$USERACCOUNT.setpassword("$PASSWORD")
$USERACCOUNT.put("PasswordExpired", 1)
$USERACCOUNT.setinfo
$USERACCOUNT = GetObject($STRUSERPATH2)
$USERACCOUNT.GetInfo
$USERACCOUNT.setpassword("$PASSWORD")
$USERACCOUNT.put("PasswordExpired", 1)
$USERACCOUNT.setinfo
$= $FORM.MsgBox("The password for user (" + $STRUSERNAME + ") has been Reset to aa123456.", "Password Reset")
$WAIT = 0 ; close the form called $WAIT
$USERACCOUNT = 0
$FORM.Refresh
$CMDEXIT.SetFocus
$CMDRESET_PASSWORD.Enabled = 0 ; Disable the reset password button
$FORM.Refresh

ENDFUNCTION