File Sharing enabled at startup

Hello world again!, I know you can enable web sharing at startup using applescript, but can you do the same with file sharing for a account that doesn’t have system prefs accessing abilities?



Also, does this form support Cocoa code too?




you can do this only this way.

edit /etc/hostconfig by changing




and then you can start and stop FileSharing from the command line

do shell script "/sbin/SystemStarter start AppleShare" user name "adminName" password "¢¢¢" with administrator privileges

At least the name and password of an admin account are required

PS: you can ask Cocoa questions in the Xcode forum. It’s actually for AppleScript Studio, but here are a few people with ObjC knowlegde

StefanK, you are the best. Thanks sooo much for all the help. Also, I just registered at

Thanks, however when I looked at this code :

Open this Scriplet in your Editor:

do shell script “/sbin/SystemStarter start AppleShare” user name “adminName” password “¢¢¢” with administrator privileges

I noted the key word: “Admin”. The accounts I am using this for are not admins. they are Managed.

Will this still work if I put it on a Managed account, also, what if the account has no password, what do I do?



user name and password must be the access data of an admin account


Can your shell script be adapted to turn the FTP option on and off to coincide with file sharing on and off. The default is no FTP when file sharing is turned on, so something extra is needed. I am running Leopard.

I was also wondering if there is a similar shell script work around to toggle internet sharing on and off?



In Leopard and higher services can (and should) be turned on/off with launchd

Basic Syntax


do shell script "/bin/launchctl load -w " & pathToServicePlist with administrator privileges


do shell script "/bin/launchctl unload -w " & pathToServicePlist with administrator privileges

administrator privileges are required! launchctl without sudo affects the agents / deamons in the user domain

Some service plist paths are:
FTP: /System/Library/LaunchDaemons/ftp.plist
FileSharing: /System/Library/LaunchDaemons/
Internet Sharing: /System/Library/LaunchDaemons/

Thanks for this Stefan. Will have a play around