Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
The only caveat that I would like to point out is that any method that attempts to peform a logon, such as RunWithLogon() or wntRunAsUser(), may trigger account lockout if too many attempts are made in too short a time with an invalid password. The end result can be false negative test results since logons fail after account lockout is triggered even if you do use the correct password.
; Password Check Utility ; Version Information on Next Line PWDChkVer = "1.0" ; ; Modification Log: ; Date and Modifier Version ; 07/13/2004 cal 1.0 ; Initial ; Input Parameters ; PwdChk Input1 Input2 ; Input1 The account you want to check the password on. ; Input2 The password you want to check for the account. ; Returns ; C:\install\pwdchksuccess.txt ; C:\install\pwdchkfailure.txt ; Extenders AddExtender("WWWNT34I.DLL") ; Pre-RunTime Variables TDSTR = TimeDate() ComputerName = Environment("COMPUTERNAME") ; Eg PS1A ; Setup Logging LogDir = "C:\Install" if !DirExist(LogDir) Then DirMake(LogDir) CLogFile = "%LogDir%\PWDChk.LOG" if FileExist(CLogFile) LogFile = FileOpen("%CLogFile%", "APPEND") else LogFile = FileOpen("%CLogFile%", "WRITE") endif FileWrite(LogFile, "%@CRLF%Password Check Utility.") FileWrite(LogFile, "%@TAB%Using Version: %PWDChkVer%") FileWrite(LogFile, "%@TAB%Run-Time: %TDSTR% %@CRLF%") SuccessFile="%LogDir%\pwdchksuccess.txt" FailureFile="%LogDir%\pwdchkfailure.txt" if FileExist(SuccessFile) then FileDelete(SuccessFile) if FileExist(FailureFile) then FileDelete(FailureFile) ; Get Run-Time Parameters If (param0 != 2) ; Missing args Goto ParamError else accttochk=param1 ;account pwdtochk=param2 ;password FileWrite(LogFile, "%@CRLF% Checking %accttochk% password.....") endif ; Programming GoSub ActCheck GoSub PwdCheck Goto Exit ; Sub-Routines :ParamError ; Input Parameter Error ParamErrorFormat=`WWWDLGED,6.1` ParamErrorCaption=`Input Parameter Error` ParamErrorX=147 ParamErrorY=156 ParamErrorWidth=180 ParamErrorHeight=087 ParamErrorNumControls=004 ParamErrorProcedure=`DEFAULT` ParamErrorFont=`DEFAULT` ParamErrorTextColor=`DEFAULT` ParamErrorBackground=`DEFAULT,DEFAULT` ParamErrorConfig=0 ParamError001=`113,065,036,012,PUSHBUTTON,DEFAULT,"OK",1,1,DEFAULT,DEFAULT,DEFAULT,DEFAULT` ParamError002=`033,007,130,012,STATICTEXT,DEFAULT,"Required Input Parameters were not supplied!",DEFAULT,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT` ParamError003=`009,027,160,010,STATICTEXT,DEFAULT,"Input Parameter 1: Account to check",DEFAULT,3,DEFAULT,DEFAULT,DEFAULT,DEFAULT` ParamError004=`009,039,160,012,STATICTEXT,DEFAULT,"Input Parameter 2: Password for the account to check.",DEFAULT,4,DEFAULT,DEFAULT,DEFAULT,DEFAULT` ButtonPushed=Dialog("ParamError") FileWrite(LogFile, "Input Parameter Error!") Goto End :ActCheck ;Check for account acctchk=wntUserExist("", "%accttochk%",0) if (acctchk == @True) ; account exists, continue. else FFile = FileOpen("%FailureFile%", "WRITE") FileWrite(FFile, "Account does not exist on this system.") FileClose(FFile) Goto End endif return :PwdCheck procID="1" ErrorMode(@off) procID=RunWithLogon("notepad.exe", "", "", @NORMAL, @GETPROCID, accttochk, ".", pwdtochk, 0) ErrorMode(@on) if (ProcID > 1) WinClose("~Notepad") SFile = FileOpen("%SuccessFile%", "WRITE") FileWrite(SFile, "Account password check passed.") FileClose(SFile) Goto End else FFile = FileOpen("%FailureFile%", "WRITE") FileWrite(FFile, "Account's Password does not match.") FileClose(FFile) Goto End endif return ;======================================================== ;Exit Routines ;======================================================== :End FileWrite(LogFile, "%@CRLF% %ProductSting% Password Check Utility Completed!") FileClose(LogFile)
Article ID: W16515
File Created: 2005:02:18:12:21:12
Last Updated: 2005:02:18:12:21:12