Help quiting script if run by a certin user.

I have a script that i do not want to run if it is run under an accoutn called test. but it dose not seem to quit like i asked. here is the scirpt

tell application "System Events" to get name of current user
set shortName to result

if shortName contains "test" then quit

tell application "System Events" to get full name of current user
set longName to result

do shell script "sudo scutil --set LocalHostName " & quoted form of shortName user name "Admin" password "password" with administrator privileges

do shell script "sudo scutil --set ComputerName " & quoted form of longName user name "Admin" password "password" with administrator privileges

hi r,

you’ve got to enclose what you don’t want to run in the if block. like this:


tell application "System Events" to get name of current user
set shortName to result

if shortName contains "test" then
	quit
else
	tell application "System Events" to get full name of current user
	set longName to result
	
	do shell script "sudo scutil --set LocalHostName " & quoted form of shortName user name "Admin" password "password" with administrator privileges
	
	do shell script "sudo scutil --set ComputerName " & quoted form of longName user name "Admin" password "password" with administrator privileges
end if

does that work better for you?