Looking for an Applescript to Change Computer Sharing Name

ra3ndy

Custom User Title
We often have temps in the office for data entry purposes. Our standard policy has been to name the temp's Macs as "TempMac1", "TempMac2", etc.

This creates a problem with FileMaker, since it saves changes to the database as "last edited by _____" where _____ is the Computer Name as set in the Sharing Preferences. It doesn't help our Data Management people to see that a file was edited by "TempMac". No one to blame for problems.

So, what I'd like to do, ideally, is have a script of some sort run at login that prompts for a name, which subsequently sets the sharing name of the computer.

Am I asking too much?
 
Definitely a good start, BobW, thanks for introducing me to that site!

The solutions you linked to require some tweaking to do exactly what i need, but definitely something for me to start playing with.

Thanks for showing a man how to fish, BobW. Hopefully I'll manage to learn something for myself.
 
Success! So here's what I came up with:

Code:
tell application "Finder"
	activate
	display dialog "Enter your name:" default answer "Your Name"
	set computerName to text returned of result
end tell


tell application "System Preferences"
	activate
	set current pane to pane "com.apple.preferences.sharing"
	tell application "System Events" to tell text field 1 of window "Sharing" of process "System Preferences"
		keystroke tab
		keystroke computerName
		keystroke " (Temp)"
		keystroke return
	end tell
	quit
end tell

Sloppy as all get out, I'm sure, but for my first Applescript, I'm just happy it works ;)

Further question: Is there a way anyone can think of to bypass the need to click the padlock when changing prefs in a non-admin account? i.e. to unlock it once and leave it unlocked by default?
 
Back
Top