Start/Stop/Status of Filesharing

Ok, some background. I’ve written a script which has a few ‘do shell script’ lines in it to setup a shared folder, as this is way easier then telling people how to do this in NetInfo Manager.

The one stumbling block I’ve come across is that once I’ve added the bits to NetInfo Manager you need to restart filesharing, if it’s on, to get the share to show up.

If this was Mac OS 9, I’d simply go:

set fsstatus to file sharing
if filesharing then
set filesharing false
– probably delay for a few seconds
set filesharing true
end if

however, this does not work under Mac OS X (did not really think it would)

Is there any applescript commands for X to get/start/stop filesharing? Or do I have to do a shell script and punt some unix command, if so, then what command do I need to send?

It would be great if I could do this, rather than have the users start and stop filesharing.

thanks for any information

Well, did a bit of hunting and think I’ve found an answer, the best solution? maybe not, but it does seem to work.

added a few more ‘do shell script’ lines to my code. They are:

do shell script “/usr/bin/sudo Killall AppleFileServer” password adminpassword with administrator privileges

That kills off the AppleFileServer process, effectively turning off file sharing

then I do:

do shell script “/usr/bin/sudo AppleFileServer” password adminpassword with administrator privileges

Which relaunches AppleFileServer, which turns file sharing back on.

Seems to work quite nicely.

If somone happens to be connect to the machine when this happens they get disconnected, but hey.