WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Password Tips

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Sample Password Change Script

Keywords:    password change script 

Question:

I'm using an Editbox in a dialogue box to allow the user to enter a password. Is there any way that I can return *'s to the screen as they're typing their password?

Answer:

Yes. Whatever variable you are using for the editbox to capture the password, start he variable name with pw_

so if you were using the variable fred then change it to pw_fred everyplace.


Question:

How would you set up a script to pop up a special dialog box to ask for a new password?

The dialog box would contain both an "enter new password" field and a "confirm new password" field. An asterisk (*) is echoed for each character that the user types; the actual characters entered are not displayed.

When the user presses the OK button or the Enter Key the "new password" will be returned provided both entered passwords are identical, otherwise an empty string is returned. If the user presses the Cancel button or the Esc key, the processing of the WIL program is canceled.

Answer:

Here's a sample script that puts up a dialog box for your users to change their passwords:
:BeginProgram
	Sounds(0)
	LF=@CRLF
	ErrorMode(@off)
	CurrentDir=DirGet()
;	CurrentDir=DirHome()
	WinDir=DirWindows(1)
	SysDir=DirWindows(1)
	CurrentTime=TimeDate()
	ProgVer="Change Password"
	AlreadyOpen=WinExist(ProgVer)
	if AlreadyOpen == @TRUE then goto End
	WinTitle("",ProgVer)

	CheckForKey=IsKeyDown(@SHIFT)
	if CheckForKey == @YES
		ProgDebug = AskYesNo(ProgVer,"Would you like Debug Mode turned ON?")
		If ProgDebug == @YES 
			Debug(@ON)
			ErrorMode(@ON)
		endif
	endif

	CheckForKey=IsKeyDown(@CTRL)
	if CheckForKey == @YES
		ProgDebug = AskYesNo(ProgVer,"Would you like to Re-Install the application?")
		If ProgDebug == @YES then goto Reload
	endif


:ShowBox

	Dialog1Format=`WWWDLGED,5.0`

	Dialog1Caption=`Change Password`
	Dialog1X=5000
	Dialog1Y=5000
	Dialog1Width=180
	Dialog1Height=98
	Dialog1NumControls=11

	Dialog101=`92,8,64,DEFAULT,EDITBOX,UserID,""`
	Dialog102=`92,30,64,DEFAULT,EDITBOX,PW_USERPSWD1,""`
	Dialog103=`92,44,64,DEFAULT,EDITBOX,PW_USERPSWD2,""`
	Dialog104=`92,58,64,DEFAULT,EDITBOX,PW_USERPSWD3,""`
	Dialog105=`28,76,36,DEFAULT,PUSHBUTTON,DEFAULT,"OK",1`
	Dialog106=`70,76,36,DEFAULT,PUSHBUTTON,DEFAULT,"Cancel",2`
	Dialog107=`112,76,36,DEFAULT,PUSHBUTTON,DEFAULT,"Help",3`
	Dialog108=`20,10,42,DEFAULT,STATICTEXT,DEFAULT,"User ID"`
	Dialog109=`20,32,42,DEFAULT,STATICTEXT,DEFAULT,"Old Password"`
	Dialog110=`20,46,42,DEFAULT,STATICTEXT,DEFAULT,"New Password"`
	Dialog111=`20,60,66,DEFAULT,STATICTEXT,DEFAULT,"Reconfirm New Password"`

	ButtonPushed=Dialog("Dialog1")

	If Buttonpushed == 1 then goto CheckID
	If Buttonpushed == 2 then goto End
	If Buttonpushed == 3 then goto HelpMsg
	goto end


:CheckID
	If UserID == "" then goto NoUserID
	
:CheckPWD
	Password1 = PW_USERPSWD1
	Password2 = PW_USERPSWD1
	UserID= Message (ProgVer,"User ID is %UserID%%LF%Old Password is %PW_USERPSWD1%%LF%New Password is %PW_USERPSWD2%%LF%Re-confirm Password is %PW_USERPSWD3%")
	goto end

:HelpMsg
	Message (ProgVer,"Sorry, no help is available yet!")

:NoUserID
	Message (ProgVer,"You must enter a username!")
	goto ShowBox

:End

Article ID:   W13310
Filename:   Sample Change Password Script.txt
File Created: 2001:04:18:10:50:04
Last Updated: 2001:04:18:10:50:04