Suppressing password dialog

I have a script that runs a shell script with admin privileges. I know how to automatically apply a stored password to this. I also have a routine that checks the stored password on entry as below:


on checkAdminPassword()	
	do shell script "sudo -k"
	delay 1
	try
		do shell script "sudo -v" password adminPasswd with administrator privileges
	on error
		return false
	end try
	return true
end checkAdminPassword

This works fine when the use enters the correct password. If the password is incorrect, the routine does return false. The problem is that the system password dialog appears asking for the password. Is there a way to suppress this password request when the password is incorrect? Is there another way to do this that will not call the dialog when the password is wrong?

Dee

You can specify the user name in both do shell script commands and it will kill the dialog. Here’s your handler with that change and it works for me:

on checkAdminPassword(adminPasswd)
	do shell script "sudo -k" user name "nitewing98"
	delay 1
	try
		do shell script "sudo -v" password adminPasswd user name "nitewing98" with administrator privileges
	on error
		return false
	end try
	return true
end checkAdminPassword

Thanks I think that this has done the trick!

Dee