2014-06-18 69 views
0

我拉我的頭髮寫一個腳本,在10.8做以下。 :蘋果腳本將文件共享關閉在一個腳本

-uncheck在「共享」中的「共享」「文件共享」 ControlPanel控制

- 檢查「文件共享」 ControlPanel控制

- 確保當腳本完成

檢查

爲什麼我想這樣做?因爲在10.8中有一個錯誤。與桑巴(不能從另一臺機器smb登錄),如果啓動時文件共享關閉了一切,一切都很好。

任何人都可以幫我解決這個問題嗎?應該是一個容易爲你們:-)

非常感謝你提前,BEST-博士!升!PP

回答

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 
+0

Thanx,很快!但是,這是否也確保腳本結束時文件共享處於打開狀態? Best- – user3752662

+0

我編輯了代碼,現在它會切換兩次首選項。這意味着,爲了在腳本完成時讓文件共享,在運行腳本之前,您將需要它。 –

+0

再次感謝!我想,延遲1 3(..?)點擊是需要關閉和回...無論如何,它得到它的工作now.thx再次&最好 - – user3752662