Apple脚本关闭文件共享&在一个脚本中

时间:2014-06-18 13:12:58

标签: macos applescript osx-mountain-lion file-sharing

我正在拔头发写一个脚本,在10.8中执行以下操作。 :

在“共享”控制面板中启用“文件共享”

- 在“共享”控制面板中检查“文件共享”

- 确保在脚本完成时检查

为什么我要这样做?因为10.8中有一个错误。使用Samba(不能从另一台机器上登录smb),如果文件共享在启动时关闭,一切都很好。

任何人都可以帮我解决这个问题吗?对你们来说应该很容易: - )

非常感谢你,最好的Ph!L!pp

1 个答案:

答案 0 :(得分:0)

此代码应切换共享首选项,等待1秒钟,然后再次切换它们。

tell application "System Preferences"
 activate
end tell

tell application "System Events"
tell process "System Preferences"
click menu item "Sharing" of menu "View" of menu bar 1
delay 2
tell window "Sharing"
  click checkbox 1 of row 3 of table 1 of scroll area 1 of group 1
  delay 1
  if (exists sheet 1) then
    if (exists button "Turn AirPort On" of sheet 1) then
      click button "Turn AirPort On" of sheet 1
      delay 1
    end if
    click button "Start" of sheet 1
  end if
end tell
end tell
end tell
delay 1
tell application "System Events"
tell process "System Preferences"
click menu item "Sharing" of menu "View" of menu bar 1
delay 2
tell window "Sharing"
  click checkbox 1 of row 3 of table 1 of scroll area 1 of group 1
  delay 1
  if (exists sheet 1) then
    if (exists button "Turn AirPort On" of sheet 1) then
      click button "Turn AirPort On" of sheet 1
      delay 1
    end if
    click button "Start" of sheet 1
  end if
end tell
end tell
end tell