2017-02-14 166 views
0

這個蘋果腳本被保存爲應用程序Mac_restart.app 運行Mac_restart.app mac重新啓動後,重新啓動後,該應用程序仍然在Dock上作爲運行應用程序,我可以再次點擊重新啓動,我已經添加了應用程序退出,但它沒有工作。 我想重新啓動後很想這個應用程序,並且不想在Dock上打開應用程序。 我錯過了什麼?善意幫助。蘋果腳本重新啓動並重新啓動後退出應用程序

,如果我不把嘗試在整個腳本的應用程序一段時間的AppleEvent超時(-1712)後,將拋出錯誤,我可以看到,我不希望這樣的編輯選項就是爲什麼它把整個上如果我把上面的處理程序嘗試,它仍然會繼續重新啓動我想直到我按下重新啓動它壽衣不重新啓動。 下面是重啓後沒有退出應用程序的最終應用程序。休息工作正常。

try 
    with timeout of 400 seconds 
     tell application "Finder" 
      display dialog "Create Folder & Restart." buttons {"Cancel", "Ok"} default button 1 with icon 0 with title "Create Folder & Restart" giving up after 400 
      if the button returned of the result is "Cancel" then 
       return 
      end if 
     end tell 
    end timeout 

    try 
     do shell script "mkdir -p /Volumes/MAC/Users/jack/Desktop/2014" 
     do shell script "mkdir -p /Volumes/MAC/Users/jack/Desktop/2015" 
     do shell script "mkdir -p /Volumes/MAC/Users/jack/Desktop/2016" 
     do shell script "mkdir -p /Volumes/MAC/Users/jack/Desktop/2017" 
    end try 

    tell application "Finder" 
     activate 
     display dialog "Click on Restart." with icon 0 buttons ("Restart") giving up after 60 
    end tell 
    tell application "Finder" 
     restart 
    end tell 
end try 

回答

0

如果腳本被保存爲應用程序中使用on quit處理

on run 
    tell application "Finder" 
     activate 
     display dialog "Computer restart " with title "Restart Mac" with icon 0 buttons ("Restart Now") 
    end tell 
    quit 
end run 

on quit 
    tell application "Finder" to restart 
    continue quit 
end quit 
+0

它不工作同它仍然在重新啓動後,碼頭,問我要再次重新啓動。 – Skull

+0

它可能與腳本語法無關。用'beep'而不是'restart'來證明它。腳本將退出。 – vadian

+0

如果整個腳本都在'try'中,則不會在運行時執行'on quit'' .. !!!! '嘗試 上運行 告訴應用程序「發現者」 激活 顯示對話框中的「重新啓動計算機」標題爲「重新啓動的Mac」使用圖標0按鈕(「現在重啓」) 端告訴 退出 運行結束 退出 告訴應用程序「Finder」重新啓動 繼續退出 結束退出 結束嘗試' – Skull