« [LSSharedFileList]Finderサイドバーのよく使う項目を追加する | トップページ | [com.microsoft.teams2]Microsoft Teams (work or school)キャッシュクリア »

[com.microsoft.teams2]Microsoft Teams (work or school)終了


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
# Microsoft Teams (work or school)の関連アプリの強制終了用
# 先に主要なアプリは終了させてから 例えばAcrobatは終了させてから実行
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKIt"
use framework "UniformTypeIdentifiers"
use scripting additions
property refMe : a reference to current application

set listAppBundleID to {"com.microsoft.teams2", "com.microsoft.teams2.modulehost", "com.microsoft.teams2.helper", "com.microsoft.teams2.launcher", "com.microsoft.teams2.notificationcenter", "com.microsoft.teams2.teamsswitcher"} as list


###まずは通常終了 を試みる
repeat with itemBundleID in listAppBundleID
  set strBundleID to itemBundleID as text
  try
    with timeout of 3 seconds
      tell application id strBundleID to quit
    end timeout
  on error
log "終了出来いORプロセスなし:" & strBundleID
  end try
end repeat
delay 1
repeat with itemBundleID in listAppBundleID
  set strBundleID to itemBundleID as text
  set ocidRunningApplication to refMe's NSRunningApplication
  set ocidAppArray to (ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID))
  repeat with itemAppArray in ocidAppArray
itemAppArray's terminate
  end repeat
end repeat
delay 1
###強制終了
repeat with itemBundleID in listAppBundleID
  set strBundleID to itemBundleID as text
  set ocidRunningApplication to refMe's NSRunningApplication
  set ocidAppArray to (ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID))
  repeat with itemAppArray in ocidAppArray
itemAppArray's forceTerminate
  end repeat
end repeat


###まずは通常終了 を試みる
repeat with itemBundleID in listAppBundleID
  set strBundleID to itemBundleID as text
  try
    with timeout of 3 seconds
      tell application id strBundleID to quit
    end timeout
  on error
log "終了出来なかった:" & strBundleID
  end try
end repeat
delay 1
###通常終了
log "通常終了開始"
repeat with itemBundleID in listAppBundleID
  set strBundleID to itemBundleID as text
  set ocidRunningApplication to refMe's NSRunningApplication
  set ocidAppArray to (ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID))
  repeat with itemAppArray in ocidAppArray
itemAppArray's terminate
  end repeat
end repeat
delay 1
log "強制終了開始"
###強制終了
repeat with itemBundleID in listAppBundleID
  set strBundleID to itemBundleID as text
  set ocidRunningApplication to refMe's NSRunningApplication
  set ocidAppArray to (ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID))
  repeat with itemAppArray in ocidAppArray
itemAppArray's forceTerminate
  end repeat
end repeat

###
repeat with itemBundleID in listAppBundleID
  set strBundleID to itemBundleID as text
  set ocidRunningApplication to refMe's NSRunningApplication
  set ocidAppArray to (ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID))
  repeat with itemAppArray in ocidAppArray
    set ocidProcess to itemAppArray's processIdentifier()
log ocidProcess
  end repeat
end repeat



###
repeat with itemBundleID in listAppBundleID
  set strBundleID to itemBundleID as text
  set ocidRunningApplication to refMe's NSRunningApplication
  set ocidAppArray to (ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID))
  repeat with itemAppArray in ocidAppArray
    set strPID to itemAppArray's processIdentifier()
    set strCommandText to ("/bin/kill -9 " & strPID & "") as text
do shell script strCommandText
  end repeat
end repeat


|

« [LSSharedFileList]Finderサイドバーのよく使う項目を追加する | トップページ | [com.microsoft.teams2]Microsoft Teams (work or school)キャッシュクリア »

AppleScript Microsoft」カテゴリの記事