Name

File Sharing

Syntax

tell app "File Sharing"
   (* find out about the first user connected to your machine *)
   name of connected user 1
end tell

Dictionary commands

close reference to object

You can close a File Sharing window used to set or alter the privileges for a user or group:

close user "Guest"

This window can be opened from the Users & Groups tab by selecting the username and clicking the Open button (AppleScript cannot open this window, however).

delete reference to object

You can delete a user or group:

delete user "temp"

You should not allow important network script commands like delete or make to fall into the wrong hands.

duplicate list

You can create a new user or group with the same privileges as another user or group with duplicate. The following example duplicates a user and gives the new user a name:

tell application "File Sharing"
   activate
   set nw_user to duplicate user "iMarc"
   set name of nw_user to "iMarc2"
end tell

make

This command makes a new user, but the with data parameter that is identified in its dictionary does not work.

new user or group

You can make either a new user or group; you cannot make a new shared item.

with data anything

Alas, this parameter does not work properly with making new users or groups in AppleScript 1.4, but I include it anyway because it appears in the File Sharing dictionary. The next example shows user- and group-creating code that does work:

tell application "File Sharing" activate set group_name to "graphics" set user_name ...

Get AppleScript in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.