Microsoft

[LINK]Teams 2

Teams app
Release yearRelease dateTeams versionLink
2024November 11 (Rolling out)24295.606.3238.6194LINK
2024November 0124277.3502.3161.3007LINK
2024October 1124256.2503.3156.9924LINK
2024October 0124244.507.3125.3475LINK
2024September 2324231.509.3122.5539LINK
2024September 0224215.1002.3039.5089LINK
2024August 0724193.1707.3028.4282LINK
2024July 3124180.210.3001.6635LINK
2024July 1024165.1406.2974.9471LINK
2024June 2524152.405.2925.6762LINK
2024June 1724137.2012.2930.9819LINK
2024June 0724124.1412.2911.3341LINK
2024May 2124102.2214.2869.7475LINK
2024May 1324091.213.2852.3731LINK
2024April 1624074.2607.2799.9843LINK
2024April 0524060.2809.2788.1256LINK
2024March 2724046.2813.2770.1094LINK
2024March 0824033.812.2721.9190LINK
2024February 1424004.1304.2655.7488LINK
2024January 1823335.208.2601.834LINK
2024January 1123320.3110.2622.1325LINK
2023December 1223306.3408.2576.5406LINK
2023November 1723285.3809.2525.961LINK
2023October 1823272.2708.2452.9689LINK
2023October 0423247.720.2421.8365LINK
@20241121

|

[LINK]Teams Classic

Classic Teams
Release yearRelease dateTeams versionLINK
2024October 181.7.00.27854LINK
2024September 201.7.00.25763LINK
2024September 091.7.00.24661LINK
2024July 241.7.00.19151LINK
2024July 021.7.00.16352LINK
2024June 141.7.00.15956LINK
2024May 231.7.00.13452LINK
2024April 101.7.00.9457LINK
2024March 081.7.00.5951LINK
2024February 141.7.00.3856LINK
2024January 311.7.00.1859LINK
2024January 081.6.00.35956LINK
2023November 081.6.00.29954LINK
2023October 091.6.00.27656LINK
2023September 131.6.00.24065LINK
2023August 141.6.00.22155LINK
2023July 121.6.00.17554LINK
2023June 071.6.00.12966LINK
2023May 081.6.00.11156LINK
2023April 031.6.00.7354LINK
2023March 161.6.00.4464LINK
2023February 101.6.00.1159LINK
2023January 311.6.00.364LINK
2022December 071.5.00.33356LINK
2022November 171.5.00.31156LINK
2022October 181.5.00.26358LINK
2022August 301.5.00.22362LINK
2022August 151.5.00.21551LINK
2022July 051.5.00.17261LINK
2022May 311.5.00.12661LINK
2022May 021.5.00.11157LINK
2022April 191.5.00.9159LINK
@2024112

|

[bash] Microsoft Teams2 アップデート 途中


サンプルコード

サンプルソース(参考)
行番号ソース
001#!/bin/bash
002#com.cocolog-nifty.quicktimer.icefloe
003# com.microsoft.teams2のアップデート用
004########################################
005###管理者インストールしているか?チェック
006USER_WHOAMI=$(/usr/bin/whoami)
007/bin/echo "実行したユーザーは:$USER_WHOAMI"
008if [ "$USER_WHOAMI" != "root" ]; then
009/bin/echo "このスクリプトを実行するには管理者権限が必要です。"
010/bin/echo "sudo で実行してください"
011### path to me
012SCRIPT_PATH="${BASH_SOURCE[0]}"
013/bin/echo "/usr/bin/sudo \"$SCRIPT_PATH\""
014/bin/echo "↑を実行してください"
015exit 1
016else
017###実行しているユーザー名
018CURRENT_USER=$(/bin/echo "$HOME" | /usr/bin/awk -F'/' '{print $NF}')
019/bin/echo "実行ユーザー:" "$CURRENT_USER"
020fi
021###コンソールユーザー CONSOLE_USERはFinderでログインしていないと出ない
022CONSOLE_USER=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/ { print $3 }')
023if [ -z "$CONSOLE_USER" ]; then
024/bin/echo "コンソールユーザーが無い=電源入れてログインウィンドウ状態"
025else
026/bin/echo "コンソールユーザー:" "$CONSOLE_USER"
027  ###STAT
028  STAT_USR=$(/usr/bin/stat -f%Su /dev/console)
029  /bin/echo "STAT_USR(console): $STAT_USR"
030fi
031
032########################################
033##OS
034PLIST_PATH="/System/Library/CoreServices/SystemVersion.plist"
035STR_OS_VER=$(/usr/bin/defaults read "$PLIST_PATH" ProductVersion)
036/bin/echo "OS VERSION :" "$STR_OS_VER"
037STR_MAJOR_VERSION="${STR_OS_VER%%.*}"
038/bin/echo "STR_MAJOR_VERSION :" "$STR_MAJOR_VERSION"
039STR_MINOR_VERSION="${STR_OS_VER#*.}"
040/bin/echo "STR_MINOR_VERSION :" "$STR_MINOR_VERSION"
041
042########################################
043###ローカルのユーザーアカウントを取得
044TEXT_RESULT=$(/usr/bin/dscl localhost -list /Local/Default/Users PrimaryGroupID | /usr/bin/awk '$2 == 20 { print $1 }')
045###リストにする
046read -d '\\n' -r -a LIST_USER <<<"$TEXT_RESULT"
047###リスト内の項目数
048NUM_CNT=${#LIST_USER[@]}
049/bin/echo "ユーザー数:" "$NUM_CNT"
050
051
052########################################
053STR_DEVICE_UUID=$(/usr/sbin/ioreg -c IOPlatformExpertDevice | grep IOPlatformUUID | awk -F'"' '{print $4}')
054/bin/echo "デバイスUUID: " "$STR_DEVICE_UUID"
055###各ユーザーの最終ログアウト日
056for ITEM_LIST in "${LIST_USER[@]}"; do
057STR_CHECK_File_PATH="/Users/${ITEM_LIST}/Library/Preferences/ByHost/com.apple.loginwindow.$STR_DEVICE_UUID.plist"
058STR_LAST_LOGOUT=$(/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/stat -f "%Sm" -t "%Y-%m-%d %H:%M:%S" "$STR_CHECK_File_PATH")
059/bin/echo "ユーザー$ITEM_LIST の最終ログアウト日: " "$STR_LAST_LOGOUT"
060done
061########################################
062##デバイス
063#起動ディスクの名前を取得する
064for ITEM_LIST in "${LIST_USER[@]}"; do
065/usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "/Users/${ITEM_LIST}/Documents/Apple/IOPlatformUUID/"
066/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "/Users/${ITEM_LIST}/Documents/Apple/IOPlatformUUID/com.apple.diskutil.plist"
067/usr/bin/sudo -u "${ITEM_LIST}" /usr/sbin/diskutil info -plist / >"/Users/${ITEM_LIST}/Documents/Apple/IOPlatformUUID/com.apple.diskutil.plist"
068STARTUPDISK_NAME=$(/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/defaults read "/Users/${ITEM_LIST}/Documents/Apple/IOPlatformUUID/com.apple.diskutil.plist" VolumeName)
069done
070/bin/echo "ボリューム名:" "$STARTUPDISK_NAME"
071########################################
072###ダウンロード起動時に削除する項目
073for ITEM_LIST in "${LIST_USER[@]}"; do
074USER_TEMP_DIR=$(/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/mktemp -d)
075/bin/echo "起動時に削除されるディレクトリ:" "$USER_TEMP_DIR"
076done
077########################################
078##基本メンテナンス
079########################################
080for ITEM_LIST in "${LIST_USER[@]}"; do
081/usr/bin/sudo -u "${ITEM_LIST}" /bin/chmod 700 "/Users/${ITEM_LIST}/Library"
082##ライブラリの不可視属性を解除
083/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/chflags nohidden "/Users/${ITEM_LIST}/Library"
084/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/SetFile -a v "/Users/${ITEM_LIST}/Library"
085## Managed Itemsフォルダを作る
086/usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "/Users/${ITEM_LIST}/Library/Managed Items"
087/usr/bin/sudo -u "${ITEM_LIST}" /bin/chmod 755 "/Users/${ITEM_LIST}/Library/Managed Items"
088/usr/bin/sudo -u "${ITEM_LIST}" /usr/sbin/chown "${ITEM_LIST}" "/Users/${ITEM_LIST}/Library/Managed Items"
089/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "/Users/${ITEM_LIST}/Library/Managed Items/.localized"
090##
091/bin/chmod 777 "/Users/${ITEM_LIST}/Library/Caches"
092/bin/chmod 777 /Users/"${ITEM_LIST}"/Library/Caches/*
093##
094/bin/chmod -Rf 755 "/Users/${ITEM_LIST}/Library/Fonts"
095/usr/sbin/chown -Rf "${ITEM_LIST}" "/Users/${ITEM_LIST}/Library/Fonts"
096##
097/bin/echo "ライブラリチェックDONE:" "${ITEM_LIST}"
098done
099########################################
100## HOME
101########################################
102for ITEM_LIST in "${LIST_USER[@]}"; do
103##  Developer
104STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Developer"
105/usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
106/bin/chmod 700 "$STR_CHECK_DIR_PATH"
107/usr/bin/sudo /usr/sbin/chown "${ITEM_LIST}" "$STR_CHECK_DIR_PATH"
108/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
109##  bin
110STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/bin"
111/usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
112/bin/chmod 700 "$STR_CHECK_DIR_PATH"
113/usr/bin/sudo /usr/sbin/chown "${ITEM_LIST}" "$STR_CHECK_DIR_PATH"
114##アクセス権チェック
115/bin/chmod 700 "/Users/${ITEM_LIST}/Movies"
116/bin/chmod 700 /"Users/${ITEM_LIST}/Music"
117/bin/chmod 700 "/Users/${ITEM_LIST}/Pictures"
118/bin/chmod 700 "/Users/${ITEM_LIST}/Downloads"
119/bin/chmod 700 "/Users/${ITEM_LIST}/Documents"
120/bin/chmod 700 "/Users/${ITEM_LIST}/Desktop"
121##全ローカルユーザーに対して実施したい処理があれば追加する
122/bin/echo "ユーザーディレクトリチェックDONE" "${ITEM_LIST}"
123done
124########################################
125##  Public
126########################################
127for ITEM_LIST in "${LIST_USER[@]}"; do
128/bin/chmod 755 "/Users/${ITEM_LIST}/Public"
129##
130STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Drop Box"
131/usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
132/bin/chmod 733 "$STR_CHECK_DIR_PATH"
133/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
134/usr/bin/chgrp -Rf nobody "$STR_CHECK_DIR_PATH"
135##########
136STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Documents"
137/usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
138/bin/chmod 700 "$STR_CHECK_DIR_PATH"
139/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
140/usr/bin/chgrp -Rf admin "$STR_CHECK_DIR_PATH"
141##
142STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Downloads"
143/usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
144/bin/chmod 700 "$STR_CHECK_DIR_PATH"
145/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
146/usr/bin/chgrp -Rf admin "$STR_CHECK_DIR_PATH"
147##
148STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Favorites"
149/usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
150/bin/chmod 700 "$STR_CHECK_DIR_PATH"
151/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
152/usr/bin/chgrp -Rf admin "$STR_CHECK_DIR_PATH"
153##########
154STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Groups"
155/usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
156/bin/chmod 770 "$STR_CHECK_DIR_PATH"
157/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
158/usr/bin/chgrp -Rf staff "$STR_CHECK_DIR_PATH"
159##
160STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Shared"
161/usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
162/bin/chmod 750 "$STR_CHECK_DIR_PATH"
163/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
164/usr/bin/chgrp -Rf staff "$STR_CHECK_DIR_PATH"
165##########
166STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Guest"
167/usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
168/bin/chmod 777 "$STR_CHECK_DIR_PATH"
169/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
170/usr/bin/chgrp -Rf nobody "$STR_CHECK_DIR_PATH"
171##
172STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Shared Items"
173/usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
174/bin/chmod 775 "$STR_CHECK_DIR_PATH"
175/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
176/usr/bin/chgrp -Rf nobody "$STR_CHECK_DIR_PATH"
177/bin/echo "パブリックチェックDONE" "${ITEM_LIST}"
178done
179########################################
180##  Applications
181########################################
182##  Applications
183for ITEM_LIST in "${LIST_USER[@]}"; do
184STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Applications"
185/usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
186/bin/chmod 700 "$STR_CHECK_DIR_PATH"
187/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
188##サブフォルダを作る
189LIST_SUB_DIR_NAME=("Demos" "Desktop" "Developer" "Documents" "Downloads" "Favorites" "Groups" "Library" "Movies" "Music" "Pictures" "Public" "Shared" "Sites" "System" "Users" "Utilities")
190##リストの数だけ処理
191for ITEM_DIR_NAME in "${LIST_SUB_DIR_NAME[@]}"; do
192/usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH/$ITEM_DIR_NAME"
193/bin/chmod 700 "$STR_CHECK_DIR_PATH/${ITEM_DIR_NAME}"
194/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/$ITEM_DIR_NAME/.localized"
195done
196done
197########################################
198##シンボリックリンクを作る
199if [[ ! -e "/Users/$CURRENT_USER/Applications/Applications" ]]; then
200/bin/ln -s "/Applications" "/Users/$CURRENT_USER/Applications/Applications"
201fi
202if [[ ! -e "/Users/$CURRENT_USER/Applications/Utilities/Finder Applications" ]]; then
203/bin/ln -s "/System/Library/CoreServices/Finder.app/Contents/Applications" "/Users/$CURRENT_USER/Applications/Utilities/Finder Applications"
204fi
205if [[ ! -e "/Users/$CURRENT_USER/Applications/Utilities/Finder Libraries" ]]; then
206/bin/ln -s "/System/Library/CoreServices/Finder.app/Contents/Resources/MyLibraries" "/Users/$CURRENT_USER/Applications/Utilities/Finder Libraries"
207fi
208if [[ ! -e "/Users/$CURRENT_USER/Applications/Utilities/System Applications" ]]; then
209/bin/ln -s "/System/Library/CoreServices/Applications" "/Users/$CURRENT_USER/Applications/Utilities/System Applications"
210fi
211if [[ ! -e "/Users/$CURRENT_USER/Applications/Utilities/System Utilities" ]]; then
212/bin/ln -s "/Applications/Utilities" "/Users/$CURRENT_USER/Applications/Utilities/System Utilities"
213fi
214
215
216#################################
217#インストール基本
218#################################
219###
220STR_URL="https://go.microsoft.com/fwlink/?linkid=2249065"
221#"https://go.microsoft.com/fwlink/?linkid=2249065"
222###
223STR_APP_NAME="Microsoft Teams.app"
224###
225STR_PLIST_PATH="/Applications/$STR_APP_NAME/Contents/Info.plist"
226STR_BUNDLE_ID="com.microsoft.teams2"
227STR_BUNDLE_ID=$(/usr/bin/defaults read "$STR_PLIST_PATH" CFBundleIdentifier)
228###アプリケーション終了
229/usr/bin/sudo -u "$SUDO_USER" /usr/bin/osascript -e "tell application id \"$STR_BUNDLE_ID\" to quit"
230
231##念の為 KILLもする
232/usr/bin/killall "Teams" 2>/dev/null
233/usr/bin/killall "Microsoft Teams" 2>/dev/null
234/usr/bin/killall "Microsoft Teams Helper"
235/usr/bin/killall "Microsoft Teams Helper (GPU)"
236/usr/bin/killall "Microsoft Teams Helper (Renderer)"
237/bin/echo "アプリケーション終了"
238/bin/sleep 2
239#################################
240#以下定型
241#################################
242###起動時に削除される項目
243LOCAL_TMP_DIR=$(/usr/bin/sudo -u "$SUDO_USER" /usr/bin/mktemp -d)
244/bin/echo "TMPDIR:" "$LOCAL_TMP_DIR"
245###ファイル名を取得
246PKG_FILE_NAME=$(/usr/bin/curl -s -L -I -o /dev/null -w '%{url_effective}' "$STR_URL" | /usr/bin/rev | /usr/bin/cut -d'/' -f1 | /usr/bin/rev)
247/bin/echo "PKG_FILE_NAME" "$PKG_FILE_NAME"
248
249###ファイル名指定してダウンロード
250/usr/bin/sudo -u "$SUDO_USER" /usr/bin/curl -L -o "$LOCAL_TMP_DIR/$PKG_FILE_NAME" "$STR_URL" --http1.1 --connect-timeout 20
251/bin/echo "インストーラーダウンロードDone"
252
253### インストール(上書き)を実行する
254/usr/sbin/installer -pkg "$LOCAL_TMP_DIR/$PKG_FILE_NAME" -target / -dumplog -allowUntrusted -lang ja
255/bin/echo "インストールDone"
256
257/usr/sbin/installer -pkg "/Applications/Microsoft Teams.app/Contents/SharedSupport/MSTeamsAudioDevice.pkg" -target / -dumplog -allowUntrusted -lang ja
258/bin/echo "MSTeamsAudioDeviceインストールDone"
259
260
261################################################
262###設定項目
263STR_BUNDLEID="com.microsoft.teams"
264STR_APP_PATH="/Applications/Microsoft Teams classic.app"
265###アプリケーション名を取得
266STR_APP_NAME=$(/usr/bin/defaults read "$STR_APP_PATH/Contents/Info.plist" CFBundleDisplayName)
267if [ -z "$STR_APP_NAME" ]; then
268STR_APP_NAME=$(/usr/bin/defaults read "$STR_APP_PATH/Contents/Info.plist" CFBundleName)
269fi
270/bin/echo "アプリケーション名: $STR_APP_NAME"
271################################################
272### DOCKに登録済みかゴミ箱に入れる前に調べておく
273##Dockの登録数を調べる
274JSON_PERSISENT_APPS=$(/usr/bin/sudo -u "$SUDO_USER" /usr/bin/defaults read com.apple.dock persistent-apps)
275NUN_CNT_ITEM=$(/bin/echo "$JSON_PERSISENT_APPS" | grep -o "tile-data" | wc -l)
276/bin/echo "Dock登録数:$NUN_CNT_ITEM"
277##Dockの登録数だけ繰り返し
278NUM_CNT=0           #カウンタ初期化
279NUM_POSITION="NULL" #ポジション番号にNULL文字を入れる
280###対象のバンドルIDがDockに登録されているか順番に調べる
281while [ $NUM_CNT -lt "$NUN_CNT_ITEM" ]; do
282##順番にバンドルIDを取得して
283STR_CHK_BUNDLEID=$(/usr/bin/sudo -u "$SUDO_USER" /usr/libexec/PlistBuddy -c "Print:persistent-apps:$NUM_CNT:tile-data:bundle-identifier" "$HOME/Library/Preferences/com.apple.dock.plist")
284##対象のバンドルIDだったら
285if [ "$STR_CHK_BUNDLEID" = "$STR_BUNDLEID" ]; then
286/bin/echo "DockのポジションNO: $NUM_CNT バンドルID:$STR_CHK_BUNDLEID"
287##位置情報ポジションを記憶しておく
288NUM_POSITION=$NUM_CNT
289fi
290NUM_CNT=$((NUM_CNT + 1))
291done
292
293##結果 対象のバンドルIDが無ければ
294if [ "$NUM_POSITION" = "NULL" ]; then
295/bin/echo "Dockに未登録です"
296PLIST_DICT="<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>$STR_APP_PATH</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>"
297/usr/bin/sudo -u "$SUDO_USER" /usr/bin/defaults write com.apple.dock persistent-apps -array-add "$PLIST_DICT"
298else
299##すでに登録済みの場合は一旦削除
300/bin/echo "Dockの$NUM_POSITION に登録済み 削除してから同じ場所に登録しなおします"
301##削除して
302/usr/bin/sudo -u "$SUDO_USER" /usr/libexec/PlistBuddy -c "Delete:persistent-apps:$NUM_POSITION" "$HOME/Library/Preferences/com.apple.dock.plist"
303##保存
304/usr/bin/sudo -u "$SUDO_USER" /usr/libexec/PlistBuddy -c "Save" "$HOME/Library/Preferences/com.apple.dock.plist"
305###同じ内容を作成する
306/usr/bin/sudo -u "$SUDO_USER" /usr/libexec/PlistBuddy -c "add:persistent-apps:$NUM_POSITION dict" "$HOME/Library/Preferences/com.apple.dock.plist"
307/usr/bin/sudo -u "$SUDO_USER" /usr/libexec/PlistBuddy -c "add:persistent-apps:$NUM_POSITION:GUID integer $RANDOM$RANDOM" "$HOME/Library/Preferences/com.apple.dock.plist"
308## 想定値 file-tile directory-tile
309/usr/bin/sudo -u "$SUDO_USER" /usr/libexec/PlistBuddy -c "add:persistent-apps:$NUM_POSITION:tile-type string file-tile" "$HOME/Library/Preferences/com.apple.dock.plist"
310###↑この親Dictに子要素としてtile-dataをDictで追加
311/usr/bin/sudo -u "$SUDO_USER" /usr/libexec/PlistBuddy -c "add:persistent-apps:$NUM_POSITION:tile-data dict" "$HOME/Library/Preferences/com.apple.dock.plist"
312###↑子要素のtile-dataにキーと値を入れていく
313/usr/bin/sudo -u "$SUDO_USER" /usr/libexec/PlistBuddy -c "add:persistent-apps:$NUM_POSITION:tile-data:showas integer 0" "$HOME/Library/Preferences/com.apple.dock.plist"
314## 想定値 2:フォルダ 41:アプリケーション 169 Launchpad とMission Control
315/usr/bin/sudo -u "$SUDO_USER" /usr/libexec/PlistBuddy -c "add:persistent-apps:$NUM_POSITION:tile-data:file-type integer 41" "$HOME/Library/Preferences/com.apple.dock.plist"
316/usr/bin/sudo -u "$SUDO_USER" /usr/libexec/PlistBuddy -c "add:persistent-apps:$NUM_POSITION:tile-data:displayas integer 0" "$HOME/Library/Preferences/com.apple.dock.plist"
317/usr/bin/sudo -u "$SUDO_USER" /usr/libexec/PlistBuddy -c "add:persistent-apps:$NUM_POSITION:tile-data:parent-mod-date integer $(date '+%s')" "$HOME/Library/Preferences/com.apple.dock.plist"
318/usr/bin/sudo -u "$SUDO_USER" /usr/libexec/PlistBuddy -c "add:persistent-apps:$NUM_POSITION:tile-data:file-mod-date integer $(date '+%s')" "$HOME/Library/Preferences/com.apple.dock.plist"
319/usr/bin/sudo -u "$SUDO_USER" /usr/libexec/PlistBuddy -c "add:persistent-apps:$NUM_POSITION:tile-data:file-label string $STR_APP_NAME" "$HOME/Library/Preferences/com.apple.dock.plist"
320/usr/bin/sudo -u "$SUDO_USER" /usr/libexec/PlistBuddy -c "add:persistent-apps:$NUM_POSITION:tile-data:is-beta bool false" "$HOME/Library/Preferences/com.apple.dock.plist"
321###↑この子要素のtile-dataに孫要素でfile-dataをDictで追加
322/usr/bin/sudo -u "$SUDO_USER" /usr/libexec/PlistBuddy -c "add:persistent-apps:$NUM_POSITION:tile-data:file-data dict" "$HOME/Library/Preferences/com.apple.dock.plist"
323###値を入れていく
324/usr/bin/sudo -u "$SUDO_USER" /usr/libexec/PlistBuddy -c "add:persistent-apps:$NUM_POSITION:tile-data:file-data:_CFURLStringType integer 15" "$HOME/Library/Preferences/com.apple.dock.plist"
325/usr/bin/sudo -u "$SUDO_USER" /usr/libexec/PlistBuddy -c "add:persistent-apps:$NUM_POSITION:tile-data:file-data:_CFURLString string file://$STR_APP_PATH" "$HOME/Library/Preferences/com.apple.dock.plist"
326##保存
327/usr/bin/sudo -u "$SUDO_USER" /usr/libexec/PlistBuddy -c "Save" "$HOME/Library/Preferences/com.apple.dock.plist"
328fi
329###
330/bin/echo "処理終了 DOCKを再起動します"
331/usr/bin/sudo -u "$SUDO_USER" /usr/bin/killall "Dock"
332
333
334
335################################################
336### クリーニング  ローカルドメイン
337#####不要なファイルをゴミ箱に
338function DO_MOVE_TO_TRASH_SUDO() {
339if [ -e "$1" ]; then
340/bin/mkdir -p "/private/tmp/Cleanup At Startup/Trash"
341TRASH_DIR=$(/usr/bin/mktemp -d "/private/tmp/Cleanup At Startup/Trash/Teams.XXXXXXXX")
342/bin/launchctll stop -wF "$1"
343/bin/launchctll unload -wF "$1"
344/usr/bin/sudo /bin/chmod 777 "$TRASH_DIR"
345/usr/bin/sudo /bin/mv "$1" "$TRASH_DIR"
346fi
347}
348DO_MOVE_TO_TRASH_SUDO "/Library/LaunchDaemons/com.microsoft.teams.TeamsUpdaterDaemon.plist"
349
350################################################
351### クリーニング ユーザードメイン
352### 対象ファイルを起動時に削除する項目へ入れる
353function DO_MOVE_TO_TRASH_USER() {
354local STR_DO_FILE_PATH="$1"
355local STR_DO_USERID="$2"
356
357if [ -e "$STR_DO_FILE_PATH" ]; then
358USER_TRASH_DIR=$(/usr/bin/sudo -u "$STR_DO_USERID" /usr/bin/mktemp -d "/private/tmp/Cleanup At Startup/.Trash/${STR_DO_USERID}/Edge.XXXXXXXX")
359/bin/chmod 777 "$USER_TRASH_DIR"
360/bin/mv "$STR_DO_FILE_PATH" "$USER_TRASH_DIR"
361fi
362}
363
364for ITEM_LIST in "${LIST_USER[@]}"; do
365/bin/mkdir -p "/private/tmp/Cleanup At Startup/.Trash/${ITEM_LIST}"
366DO_MOVE_TO_TRASH_USER "/Users/${ITEM_LIST}/Library/Application Support/Microsoft/Teams/Cache" "$LIST_USER"
367DO_MOVE_TO_TRASH_USER "/Users/${ITEM_LIST}/Library/Application Support/Microsoft/Teams/Code Cache" "$LIST_USER"
368DO_MOVE_TO_TRASH_USER "/Users/${ITEM_LIST}/Library/Application Support/Microsoft/Teams/Crashpad" "$LIST_USER"
369DO_MOVE_TO_TRASH_USER "/Users/${ITEM_LIST}/Library/Application Support/Microsoft/Teams/GPUCache" "$LIST_USER"
370
371DO_MOVE_TO_TRASH_USER "/Users/${ITEM_LIST}/Library/Application Support/Microsoft/Teams/Partitions/msa/Cache" "$LIST_USER"
372DO_MOVE_TO_TRASH_USER "/Users/${ITEM_LIST}/Library/Application Support/Microsoft/Teams/Partitions/msa/Code Cache" "$LIST_USER"
373DO_MOVE_TO_TRASH_USER "/Users/${ITEM_LIST}Library/Application Support/Microsoft/Teams/Partitions/msa/Crashpad" "$LIST_USER"
374DO_MOVE_TO_TRASH_USER "/Users/${ITEM_LIST}/Library/Application Support/Microsoft/Teams/Partitions/msa/GPUCache" "$LIST_USER"
375
376DO_MOVE_TO_TRASH_USER "/Users/${ITEM_LIST}/Library/Containers/com.microsoft.teams2.launcher" "$LIST_USER"
377DO_MOVE_TO_TRASH_USER "/Users/${ITEM_LIST}/Library/Containers/com.microsoft.teams2.notificationcenter" "$LIST_USER"
378
379DO_MOVE_TO_TRASH_USER "/Users/${ITEM_LIST}/Library/Containers/com.microsoft.teams2/Data/Library/Caches" "$LIST_USER"
380DO_MOVE_TO_TRASH_USER "/Users/${ITEM_LIST}/Library/Containers/com.microsoft.teams2/Data/Library/Saved Application State" "$LIST_USER"
381DO_MOVE_TO_TRASH_USER "/Users/${ITEM_LIST}/Library/Containers/com.microsoft.teams2/Data/Library/WebKit" "$LIST_USER"
382DO_MOVE_TO_TRASH_USER "/Users/${ITEM_LIST}/Library/Containers/com.microsoft.teams2/Data/Library/Logs" "$LIST_USER"
383DO_MOVE_TO_TRASH_USER "/Users/${ITEM_LIST}/Library/Containers/com.microsoft.teams2/Data/Library/Application Support/Microsoft/MSTeams/EBWebView" "$LIST_USER"
384DO_MOVE_TO_TRASH_USER "/Users/${ITEM_LIST}/Library/Containers/com.microsoft.teams2/Data/tmp" "$LIST_USER"
385
386done
387
388
389
390
391################################################
392##
393for ITEM_LIST in "${LIST_USER[@]}"; do
394STR_PLIST_PATH="/Users/${ITEM_LIST}/Library/Preferences/com.microsoft.teams2.plist"
395/usr/bin/sudo -u "${ITEM_LIST}"  /usr/bin/touch "$STR_PLIST_PATH"
396/usr/bin/sudo -u "${ITEM_LIST}"  /usr/libexec/PlistBuddy -c "Set:AppleLanguages:0 \"ja_jp\"" "$STR_PLIST_PATH"
397done
398
399for ITEM_LIST in "${LIST_USER[@]}"; do
400STR_PLIST_PATH="/Users/${ITEM_LIST}/Library/Preferences/com.microsoft.teams2.helper.plist"
401/usr/bin/sudo -u "${ITEM_LIST}"  /usr/bin/touch "$STR_PLIST_PATH"
402/usr/bin/sudo -u "${ITEM_LIST}"  /usr/libexec/PlistBuddy -c "Set:AppleLanguages:0 \"ja_jp\"" "$STR_PLIST_PATH"
403done
404
405for ITEM_LIST in "${LIST_USER[@]}"; do
406STR_PLIST_PATH="/Users/${ITEM_LIST}/Library/Containers/com.microsoft.teams2/Data/Library/Preferences/com.microsoft.teams2.plist"
407/usr/bin/sudo -u "${ITEM_LIST}"  /usr/bin/touch "$STR_PLIST_PATH"
408/usr/bin/sudo -u "${ITEM_LIST}"  /usr/libexec/PlistBuddy -c "Set:AppleLanguages:0 \"ja_jp\"" "$STR_PLIST_PATH"
409done
410
411for ITEM_LIST in "${LIST_USER[@]}"; do
412STR_PLIST_PATH="/Users/${ITEM_LIST}/Library/Containers/com.microsoft.teams2/Data/Library/Preferences/com.microsoft.teams2.helper.plist"
413/usr/bin/sudo -u "${ITEM_LIST}"  /usr/bin/touch "$STR_PLIST_PATH"
414/usr/bin/sudo -u "${ITEM_LIST}"  /usr/libexec/PlistBuddy -c "Set:AppleLanguages:0 \"ja_jp\"" "$STR_PLIST_PATH"
415done
416
417
418exit 0
419
AppleScriptで生成しました

|

Microsoft Teams classic キャッシュクリア(キャッシュをゴミ箱へ)


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
# Microsoft Teams classicのキャッシュ2ゴミ箱
# 先に主要なアプリは終了させてから 
# 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 strBundleID to ("com.microsoft.teams") as text


set appFileManager to refMe's NSFileManager's defaultManager()
###
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSCachesDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidCachesDirPathURL to ocidURLsArray's firstObject()
set ocidGo2TrashDirPathURL to ocidCachesDirPathURL's URLByAppendingPathComponent:("com.microsoft.teams")
log doMoveToTrash(ocidGo2TrashDirPathURL)
###
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationSupportDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidApplicatioocidupportDirPathURL to ocidURLsArray's firstObject()
set ocidTeamsDirPathURL to ocidApplicatioocidupportDirPathURL's URLByAppendingPathComponent:("Microsoft/Teams")
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("GPUCache")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("Code Cache")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("Cache")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("Crashpad")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("Local Storage")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("WebStorage")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("Session Storage")
log doMoveToTrash(ocidGo2TrashDirPathURL)
###
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("Partitions/msa/Service Worker")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("Partitions/msa/Local Storage")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("Partitions/msa/WebStorage")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("Partitions/msa/Session Storage")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("Partitions/msa/GPUCache")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("Partitions/msa/Code Cache")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("Partitions/msa/Cache")
log doMoveToTrash(ocidGo2TrashDirPathURL)
#
set ocidGo2TrashDirPathURL to ocidTeamsDirPathURL's URLByAppendingPathComponent:("Partitions/msa/Storage/ext")
log doMoveToTrash(ocidGo2TrashDirPathURL)
###
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidLibraryDirPathURL to ocidURLsArray's firstObject()
#
set ocidGo2TrashDirPathURL to ocidLibraryDirPathURL's URLByAppendingPathComponent:("WebKit/com.microsoft.teams")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidLibraryDirPathURL's URLByAppendingPathComponent:("Application Scripts/UBF8T346G9.com.microsoft.teams")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidLibraryDirPathURL's URLByAppendingPathComponent:("Group Containers/UBF8T346G9.com.microsoft.teams/Library/Application Support/Logs")
log doMoveToTrash(ocidGo2TrashDirPathURL)
set ocidGo2TrashDirPathURL to ocidLibraryDirPathURL's URLByAppendingPathComponent:("Group Containers/UBF8T346G9.com.microsoft.teams/Library/Caches")
log doMoveToTrash(ocidGo2TrashDirPathURL)


return

###################################
########処理 ゴミ箱に入れる
###################################
to doMoveToTrash(argFilePath)
  ###ファイルマネジャー初期化
  set appFileManager to refMe's NSFileManager's defaultManager()
  #########################################
  ###渡された値のClassを調べてとりあえずNSURLにする
  set refClass to class of argFilePath
  if refClass is list then
return "エラー:リストは処理しません"
  else if refClass is text then
log "テキストパスです"
    set ocidArgFilePathStr to (refMe's NSString's stringWithString:argFilePath)
    set ocidArgFilePath to ocidArgFilePathStr's stringByStandardizingPath
    set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath)
  else if refClass is alias then
log "エイリアスパスです"
    set strArgFilePath to (POSIX path of argFilePath) as text
    set ocidArgFilePathStr to (refMe's NSString's stringWithString:strArgFilePath)
    set ocidArgFilePath to ocidArgFilePathStr's stringByStandardizingPath
    set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath)
  else
    set refClass to (className() of argFilePath) as text
    if refClass contains "NSPathStore2" then
log "NSPathStore2です"
      set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:argFilePath)
    else if refClass contains "NSCFString" then
log "NSCFStringです"
      set ocidArgFilePath to argFilePath's stringByStandardizingPath
      set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath)
    else if refClass contains "NSURL" then
      set ocidArgFilePathURL to argFilePath
log "NSURLです"
    end if
  end if
  #########################################
  ###
  -->false
  set ocidFalse to (refMe's NSNumber's numberWithBool:false)'s boolValue
  -->true
  set ocidTrue to (refMe's NSNumber's numberWithBool:true)'s boolValue
  #########################################
  ###NSURLがエイリアス実在するか?
  set ocidArgFilePath to ocidArgFilePathURL's |path|()
  set boolFileAlias to appFileManager's fileExistsAtPath:(ocidArgFilePath)
  ###パス先が実在しないなら処理はここまで
  if boolFileAlias = false then
log ocidArgFilePath as text
log "処理中止 パス先が実在しない"
return false
  end if
  #########################################
  ###NSURLがディレクトリなのか?ファイルなのか?
  set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsDirectoryKey) |error|:(reference)
  # log (item 1 of listBoolDir)
  # log (item 2 of listBoolDir)
  # log (item 3 of listBoolDir)
  if (item 2 of listBoolDir) = ocidTrue then
    #########################################
log "ディレクトリです"
log ocidArgFilePathURL's |path| as text
    ##内包リスト
    set listResult to appFileManager's contentsOfDirectoryAtURL:ocidArgFilePathURL includingPropertiesForKeys:{refMe's NSURLPathKey} options:0 |error|:(reference)
    ###結果
    set ocidContentsPathURLArray to item 1 of listResult
    ###リストの数だけ繰り返し
    repeat with itemContentsPathURL in ocidContentsPathURLArray
      ###ゴミ箱に入れる
      set listResult to (appFileManager's trashItemAtURL:itemContentsPathURL resultingItemURL:(missing value) |error|:(reference))
    end repeat
  else
    #########################################
log "ファイルです"
    set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsAliasFileKey) |error|:(reference)
    if (item 2 of listBoolDir) = ocidTrue then
log "エイリアスは処理しません"
return false
    end if
    set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsSymbolicLinkKey) |error|:(reference)
    if (item 2 of listBoolDir) = ocidTrue then
log "シンボリックリンクは処理しません"
return false
    end if
    set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsSystemImmutableKey) |error|:(reference)
    if (item 2 of listBoolDir) = ocidTrue then
log "システムファイルは処理しません"
return false
    end if
    ###ファイルをゴミ箱に入れる
    set listResult to (appFileManager's trashItemAtURL:ocidArgFilePathURL resultingItemURL:(missing value) |error|:(reference))
  end if
return true
end doMoveToTrash



|

Microsoft Teams (work or school)バージョンチェッカー


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
(*
com.cocolog-nifty.quicktimer.icefloe
*)
#
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "UniformTypeIdentifiers"
use framework "AppKit"
use scripting additions
property refMe : a reference to current application

###アプリケーションのバンドルID
set strBundleID to "com.microsoft.teams2"

set strGetBundleID to "com.microsoft.teams2.standalone" as text
(* インストールパッケージのバンドルID
com.microsoft.office.suite.365
com.microsoft.office.suite.365.businesspro
com.microsoft.word.standalone.365
com.microsoft.excel.standalone.365
com.microsoft.powerpoint.standalone.365
com.microsoft.outlook.standalone.365
com.microsoft.outlook.standalone.365.monthly
com.microsoft.onenote.standalone.365
com.microsoft.onedrive.standalone
com.microsoft.skypeforbusiness.standalone
com.microsoft.teams.standalone
com.microsoft.teams2.standalone
com.microsoft.intunecompanyportal.standalone
com.microsoft.edge
com.microsoft.defender.standalone
com.microsoft.remotedesktop.standalone
com.microsoft.vscode.zip
com.microsoft.autoupdate.standalone
*)


set strURL to "https://macadmins.software/latest.xml" as text

set coidBaseURLStr to refMe's NSString's stringWithString:(strURL)
set ocidBaseURL to refMe's NSURL's URLWithString:(coidBaseURLStr)

################################################
###### URLRequest部分
################################################
set ocidURLRequest to refMe's NSMutableURLRequest's alloc()'s init()
ocidURLRequest's setHTTPMethod:"GET"
ocidURLRequest's setURL:(ocidBaseURL)
ocidURLRequest's addValue:"application/xml" forHTTPHeaderField:"Content-Type"
###ポストするデータは空
ocidURLRequest's setHTTPBody:(missing value)

################################################
###### データ取得
################################################
set ocidServerResponse to refMe's NSURLConnection's sendSynchronousRequest:(ocidURLRequest) returningResponse:(missing value) |error|:(reference)
###取得
set ocidXMLData to (item 1 of ocidServerResponse)
set listXMLDoc to refMe's NSXMLDocument's alloc()'s initWithData:ocidXMLData options:(refMe's NSXMLDocumentTidyXML) |error|:(reference)

set ocidXMLDoc to item 1 of listXMLDoc
set ocidRootElement to ocidXMLDoc's rootElement()

################################################
###### o365バージョン取得
################################################
repeat with itemRootElement in ocidRootElement's children()
  set strName to itemRootElement's |name|() as text
  if strName is "o365" then
    set ocido365ver to (ocidRootElement's childAtIndex:0)'s stringValue()
  end if
end repeat
#######
log ocido365ver as text

################################################
###### 各アプリケーションのUTI取得
################################################
set ocidPackageArray to ocidRootElement's elementsForName:"package"
repeat with itemackageArray in ocidPackageArray
  set ocidElementID to (itemackageArray's childAtIndex:0)'s stringValue()
log ocidElementID as text
  
end repeat


################################################
###### 対象アプリ最新のバージョン
################################################

set ocidPackageArray to ocidRootElement's elementsForName:"package"
repeat with itemackageArray in ocidPackageArray
  set numCntChild to itemackageArray's childCount() as integer
  set ocidElementID to (itemackageArray's childAtIndex:0)'s stringValue()
  if (ocidElementID as text) is strGetBundleID then
    set ocidCfbundleversionXML to (itemackageArray's childAtIndex:8)'s stringValue()
    set ocidDownloadURL to (itemackageArray's childAtIndex:(numCntChild - 1))'s stringValue()
  end if
end repeat

################################################
###### インストール済みのパージョン
################################################
set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
##バンドルからアプリケーションのURLを取得
set ocidAppBundle to (refMe's NSBundle's bundleWithIdentifier:(strBundleID))
if ocidAppBundle ≠ (missing value) then
  set ocidAppPathURL to ocidAppBundle's bundleURL()
else if ocidAppBundle = (missing value) then
  set ocidAppPathURL to (appSharedWorkspace's URLForApplicationWithBundleIdentifier:(strBundleID))
end if
##予備(アプリケーションのURL)
if ocidAppPathURL = (missing value) then
  tell application "Finder"
    try
      set aliasAppApth to (application file id strBundleID) as alias
      set strAppPath to POSIX path of aliasAppApth as text
      set strAppPathStr to refMe's NSString's stringWithString:(strAppPath)
      set strAppPath to strAppPathStr's stringByStandardizingPath()
      set ocidAppPathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(strAppPath) isDirectory:true
    on error
return "アプリケーションが見つかりませんでした"
    end try
  end tell
end if
set ocidFilePathURL to ocidAppPathURL's URLByAppendingPathComponent:("Contents/Info.plist")
#####PLISTの内容を読み込んで
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
set listReadPlistData to refMe's NSMutableDictionary's dictionaryWithContentsOfURL:ocidFilePathURL |error|:(reference)
set ocidPlistDict to item 1 of listReadPlistData
set ocidCfbundleversionPlist to ocidPlistDict's valueForKey:"CFBundleVersion"
################################################
###### リンク解決
################################################
set strDownloadURL to ocidDownloadURL as text
set strCommandText to ("/usr/bin/curl -Lvs -I -o /dev/null -w '%{url_effective}' " & strDownloadURL & "") as text
set strLocation to (do shell script strCommandText) as text

################################################
###### チェック
################################################
set strCfbundleversionXML to ocidCfbundleversionXML as text
set strCfbundleversionPlist to ocidCfbundleversionPlist as text

if strCfbundleversionXML is strCfbundleversionPlist then
  set strTitle to ("最新版を利用中です") as text
  set strCom to ("最新版を利用中です\r" & strCfbundleversionXML) as text
  set strMes to (strTitle & "\rRSS:" & strCfbundleversionXML & "\rPLIST:" & strCfbundleversionPlist & "\rLink:" & strDownloadURL & "\rLocation:" & strLocation) as text
else
  set strTitle to ("アップデートがあります:" & strCfbundleversionXML) as text
  set strCom to ("アップデートがあります\r最新:" & strCfbundleversionXML & "\r使用中:" & strCfbundleversionPlist) as text
  set strMes to ("最新版ダウンロード:" & strDownloadURL & "\r" & strLocation) as text
end if

################################################
###### ダイアログ
################################################
set appFileManager to refMe's NSFileManager's defaultManager()

####ダイアログに指定アプリのアイコンを表示する
###アイコン名をPLISTから取得
set strIconFileName to (ocidPlistDict's valueForKey:("CFBundleIconFile")) as text
###ICONのURLにして
set strPath to ("Contents/Resources/" & strIconFileName) as text
set ocidIconFilePathURL to ocidAppPathURL's URLByAppendingPathComponent:(strPath) isDirectory:false
###拡張子の有無チェック
set strExtensionName to (ocidIconFilePathURL's pathExtension()) as text
if strExtensionName is "" then
  set ocidIconFilePathURL to ocidIconFilePathURL's URLByAppendingPathExtension:"icns"
end if
##-->これがアイコンパス
log ocidIconFilePathURL's absoluteString() as text
###ICONファイルが実際にあるか?チェック
set boolExists to appFileManager's fileExistsAtPath:(ocidIconFilePathURL's |path|)
###ICONがみつかない時用にデフォルトを用意する
if boolExists is false then
  set aliasIconPath to POSIX file "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertNoteIcon.icns"
else
  set aliasIconPath to ocidIconFilePathURL's absoluteURL() as alias
  set strIconPath to ocidIconFilePathURL's |path|() as text
end if

set recordResult to (display dialog strCom with title strTitle default answer strMes buttons {"クリップボードにコピー", "終了", "ダウンロード"} default button "ダウンロード" cancel button "終了" giving up after 20 with icon aliasIconPath without hidden answer)

if button returned of recordResult is "ダウンロード" then
  tell application "Finder"
open location strLocation
  end tell
end if
if button returned of recordResult is "クリップボードにコピー" then
  try
    set strText to text returned of recordResult as text
    ####ペーストボード宣言
    set appPasteboard to refMe's NSPasteboard's generalPasteboard()
    set ocidText to (refMe's NSString's stringWithString:(strText))
appPasteboard's clearContents()
appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
  on error
    tell application "Finder"
      set the clipboard to strTitle as text
    end tell
  end try
end if


|

[com.microsoft.teams2]Microsoft Teams (work or school)キャッシュクリア


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
# Microsoft Teams (work or school)のキャッシュ2ゴミ箱
# 先に主要なアプリは終了させてから 
# 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 strBundleID to ("com.microsoft.teams2") as text


set appFileManager to refMe's NSFileManager's defaultManager()
###
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidLibraryDirPathURL to ocidURLsArray's firstObject()
#
set ocidContainersDirPathURL to ocidLibraryDirPathURL's URLByAppendingPathComponent:("Containers")
set ocidBundaleDirPathURL to ocidContainersDirPathURL's URLByAppendingPathComponent:(strBundleID)
#
set ocidCachesDirPathURL to ocidBundaleDirPathURL's URLByAppendingPathComponent:("Data/Library/Caches")
set ocidTmpDirPathURL to ocidBundaleDirPathURL's URLByAppendingPathComponent:("Data/tmp")
set ocidWebKitDirPathURL to ocidBundaleDirPathURL's URLByAppendingPathComponent:("Data/Library/WebKit")
set ocidEBWebViewDirPathURL to ocidBundaleDirPathURL's URLByAppendingPathComponent:("Data/Library/Application Support/Microsoft/MSTeams/EBWebView")
#ゴミ箱に入れる
log doMoveToTrash(ocidCachesDirPathURL)
log doMoveToTrash(ocidTmpDirPathURL)
log doMoveToTrash(ocidWebKitDirPathURL)
log doMoveToTrash(ocidEBWebViewDirPathURL)
###################################
########処理 ゴミ箱に入れる
###################################
to doMoveToTrash(argFilePath)
  ###ファイルマネジャー初期化
  set appFileManager to refMe's NSFileManager's defaultManager()
  #########################################
  ###渡された値のClassを調べてとりあえずNSURLにする
  set refClass to class of argFilePath
  if refClass is list then
return "エラー:リストは処理しません"
  else if refClass is text then
log "テキストパスです"
    set ocidArgFilePathStr to (refMe's NSString's stringWithString:argFilePath)
    set ocidArgFilePath to ocidArgFilePathStr's stringByStandardizingPath
    set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath)
  else if refClass is alias then
log "エイリアスパスです"
    set strArgFilePath to (POSIX path of argFilePath) as text
    set ocidArgFilePathStr to (refMe's NSString's stringWithString:strArgFilePath)
    set ocidArgFilePath to ocidArgFilePathStr's stringByStandardizingPath
    set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath)
  else
    set refClass to (className() of argFilePath) as text
    if refClass contains "NSPathStore2" then
log "NSPathStore2です"
      set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:argFilePath)
    else if refClass contains "NSCFString" then
log "NSCFStringです"
      set ocidArgFilePath to argFilePath's stringByStandardizingPath
      set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath)
    else if refClass contains "NSURL" then
      set ocidArgFilePathURL to argFilePath
log "NSURLです"
    end if
  end if
  #########################################
  ###
  -->false
  set ocidFalse to (refMe's NSNumber's numberWithBool:false)'s boolValue
  -->true
  set ocidTrue to (refMe's NSNumber's numberWithBool:true)'s boolValue
  #########################################
  ###NSURLがエイリアス実在するか?
  set ocidArgFilePath to ocidArgFilePathURL's |path|()
  set boolFileAlias to appFileManager's fileExistsAtPath:(ocidArgFilePath)
  ###パス先が実在しないなら処理はここまで
  if boolFileAlias = false then
log ocidArgFilePath as text
log "処理中止 パス先が実在しない"
return false
  end if
  #########################################
  ###NSURLがディレクトリなのか?ファイルなのか?
  set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsDirectoryKey) |error|:(reference)
  # log (item 1 of listBoolDir)
  # log (item 2 of listBoolDir)
  # log (item 3 of listBoolDir)
  if (item 2 of listBoolDir) = ocidTrue then
    #########################################
log "ディレクトリです"
log ocidArgFilePathURL's |path| as text
    ##内包リスト
    set listResult to appFileManager's contentsOfDirectoryAtURL:ocidArgFilePathURL includingPropertiesForKeys:{refMe's NSURLPathKey} options:0 |error|:(reference)
    ###結果
    set ocidContentsPathURLArray to item 1 of listResult
    ###リストの数だけ繰り返し
    repeat with itemContentsPathURL in ocidContentsPathURLArray
      ###ゴミ箱に入れる
      set listResult to (appFileManager's trashItemAtURL:itemContentsPathURL resultingItemURL:(missing value) |error|:(reference))
    end repeat
  else
    #########################################
log "ファイルです"
    set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsAliasFileKey) |error|:(reference)
    if (item 2 of listBoolDir) = ocidTrue then
log "エイリアスは処理しません"
return false
    end if
    set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsSymbolicLinkKey) |error|:(reference)
    if (item 2 of listBoolDir) = ocidTrue then
log "シンボリックリンクは処理しません"
return false
    end if
    set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsSystemImmutableKey) |error|:(reference)
    if (item 2 of listBoolDir) = ocidTrue then
log "システムファイルは処理しません"
return false
    end if
    ###ファイルをゴミ箱に入れる
    set listResult to (appFileManager's trashItemAtURL:ocidArgFilePathURL resultingItemURL:(missing value) |error|:(reference))
  end if
return true
end doMoveToTrash



|

[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


|

[Bash]one Driveアップデート 少し修正


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

#!/bin/bash
#com.cocolog-nifty.quicktimer.icefloe

########################################
###管理者インストールしているか?チェック
USER_WHOAMI=$(/usr/bin/whoami)
/bin/echo "実行したユーザーは:$USER_WHOAMI"
if [ "$USER_WHOAMI" != "root" ]; then
  /bin/echo "このスクリプトを実行するには管理者権限が必要です。"
  /bin/echo "sudo で実行してください"
  ### path to me
  SCRIPT_PATH="${BASH_SOURCE[0]}"
  /bin/echo "/usr/bin/sudo \"$SCRIPT_PATH\""
  /bin/echo "↑を実行してください"
  exit 1
else
  ###実行しているユーザー名
  CURRENT_USER=$(/bin/echo "$HOME" | /usr/bin/awk -F'/' '{print $NF}')
  /bin/echo "実行ユーザー:" "$CURRENT_USER"
fi
###コンソールユーザー CONSOLE_USERはFinderでログインしていないと出ない
CONSOLE_USER=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/ { print $3 }')
if [ -z "$CONSOLE_USER" ]; then
  /bin/echo "コンソールユーザーが無い=電源入れてログインウィンドウ状態"
else
  /bin/echo "コンソールユーザー:" "$CONSOLE_USER"
fi
########################################
##OS
PLIST_PATH="/System/Library/CoreServices/SystemVersion.plist"
STR_OS_VER=$(/usr/bin/defaults read "$PLIST_PATH" ProductVersion)
/bin/echo "OS VERSION :" "$STR_OS_VER"
STR_MAJOR_VERSION="${STR_OS_VER%%.*}"
/bin/echo "STR_MAJOR_VERSION :" "$STR_MAJOR_VERSION"
STR_MINOR_VERSION="${STR_OS_VER#*.}"
/bin/echo "STR_MINOR_VERSION :" "$STR_MINOR_VERSION"

########################################
###ローカルのユーザーアカウントを取得
TEXT_RESULT=$(/usr/bin/dscl localhost -list /Local/Default/Users PrimaryGroupID | /usr/bin/awk '$2 == 20 { print $1 }')
###リストにする
read -d '\\n' -r -a LIST_USER <<<"$TEXT_RESULT"
###リスト内の項目数
NUM_CNT=${#LIST_USER[@]}
/bin/echo "ユーザー数:" "$NUM_CNT"
########################################
STR_DEVICE_UUID=$(/usr/sbin/ioreg -c IOPlatformExpertDevice | grep IOPlatformUUID | awk -F'"' '{print $4}')
/bin/echo "デバイスUUID: " "$STR_DEVICE_UUID"
###各ユーザーの最終ログアウト日
for ITEM_LIST in "${LIST_USER[@]}"; do
  STR_CHECK_File_PATH="/Users/${ITEM_LIST}/Library/Preferences/ByHost/com.apple.loginwindow.$STR_DEVICE_UUID.plist"
  STR_LAST_LOGOUT=$(/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/stat -f "%Sm" -t "%Y-%m-%d %H:%M:%S" "$STR_CHECK_File_PATH")
  /bin/echo "ユーザー$ITEM_LIST の最終ログアウト日: " "$STR_LAST_LOGOUT"
done
########################################
##デバイス
#起動ディスクの名前を取得する
for ITEM_LIST in "${LIST_USER[@]}"; do
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "/Users/${ITEM_LIST}/Documents/Apple/IOPlatformUUID/"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "/Users/${ITEM_LIST}/Documents/Apple/IOPlatformUUID/diskutil.plist"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/sbin/diskutil info -plist / >"/Users/${ITEM_LIST}/Documents/Apple/IOPlatformUUID/diskutil.plist"
  STARTUPDISK_NAME=$(/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/defaults read "/Users/${ITEM_LIST}/Documents/Apple/IOPlatformUUID/diskutil.plist" VolumeName)
done
/bin/echo "ボリューム名:" "$STARTUPDISK_NAME"
########################################
###ダウンロード起動時に削除する項目
for ITEM_LIST in "${LIST_USER[@]}"; do
  USER_TEMP_DIR=$(/usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/mktemp -d)
  /bin/echo "起動時に削除されるディレクトリ:" "$USER_TEMP_DIR"
done
########################################
##基本メンテナンス
########################################
for ITEM_LIST in "${LIST_USER[@]}"; do
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/chmod 700 "/Users/${ITEM_LIST}/Library"
  ##ライブラリの不可視属性を解除
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/chflags nohidden "/Users/${ITEM_LIST}/Library"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/SetFile -a v "/Users/${ITEM_LIST}/Library"
  ## Managed Itemsフォルダを作る
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "/Users/${ITEM_LIST}/Library/Managed Items"
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/chmod 755 "/Users/${ITEM_LIST}/Library/Managed Items"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/sbin/chown "${ITEM_LIST}" "/Users/${ITEM_LIST}/Library/Managed Items"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "/Users/${ITEM_LIST}/Library/Managed Items/.localized"
  ##
  /bin/chmod 777 "/Users/${ITEM_LIST}/Library/Caches"
  /bin/chmod 777 /Users/"${ITEM_LIST}"/Library/Caches/*
  ##
  /bin/chmod -Rf 755 "/Users/${ITEM_LIST}/Library/Fonts"
  /usr/sbin/chown -Rf "${ITEM_LIST}" "/Users/${ITEM_LIST}/Library/Fonts"
  ##
  /bin/echo "ライブラリチェックDONE:" "${ITEM_LIST}"
done
########################################
## HOME
########################################
for ITEM_LIST in "${LIST_USER[@]}"; do
  ## Developer
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Developer"
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /bin/chmod 700 "$STR_CHECK_DIR_PATH"
  /usr/bin/sudo /usr/sbin/chown "${ITEM_LIST}" "$STR_CHECK_DIR_PATH"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  ## bin
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/bin"
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /bin/chmod 700 "$STR_CHECK_DIR_PATH"
  /usr/bin/sudo /usr/sbin/chown "${ITEM_LIST}" "$STR_CHECK_DIR_PATH"
  ##アクセス権チェック
  /bin/chmod 700 "/Users/${ITEM_LIST}/Movies"
  /bin/chmod 700 /"Users/${ITEM_LIST}/Music"
  /bin/chmod 700 "/Users/${ITEM_LIST}/Pictures"
  /bin/chmod 700 "/Users/${ITEM_LIST}/Downloads"
  /bin/chmod 700 "/Users/${ITEM_LIST}/Documents"
  /bin/chmod 700 "/Users/${ITEM_LIST}/Desktop"
  ##全ローカルユーザーに対して実施したい処理があれば追加する
  /bin/echo "ユーザーディレクトリチェックDONE" "${ITEM_LIST}"
done
########################################
## Public
########################################
for ITEM_LIST in "${LIST_USER[@]}"; do
  /bin/chmod 755 "/Users/${ITEM_LIST}/Public"
  ##
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Drop Box"
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /bin/chmod 733 "$STR_CHECK_DIR_PATH"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  /usr/bin/chgrp -Rf nobody "$STR_CHECK_DIR_PATH"
  ##########
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Documents"
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /bin/chmod 700 "$STR_CHECK_DIR_PATH"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  /usr/bin/chgrp -Rf admin "$STR_CHECK_DIR_PATH"
  ##
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Downloads"
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /bin/chmod 700 "$STR_CHECK_DIR_PATH"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  /usr/bin/chgrp -Rf admin "$STR_CHECK_DIR_PATH"
  ##
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Favorites"
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /bin/chmod 700 "$STR_CHECK_DIR_PATH"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  /usr/bin/chgrp -Rf admin "$STR_CHECK_DIR_PATH"
  ##########
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Groups"
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /bin/chmod 770 "$STR_CHECK_DIR_PATH"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  /usr/bin/chgrp -Rf staff "$STR_CHECK_DIR_PATH"
  ##
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Shared"
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /bin/chmod 750 "$STR_CHECK_DIR_PATH"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  /usr/bin/chgrp -Rf staff "$STR_CHECK_DIR_PATH"
  ##########
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Guest"
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /bin/chmod 777 "$STR_CHECK_DIR_PATH"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  /usr/bin/chgrp -Rf nobody "$STR_CHECK_DIR_PATH"
  ##
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Public/Shared Items"
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /bin/chmod 775 "$STR_CHECK_DIR_PATH"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  /usr/bin/chgrp -Rf nobody "$STR_CHECK_DIR_PATH"
  /bin/echo "パブリックチェックDONE" "${ITEM_LIST}"
done
########################################
## Applications
########################################
## Applications
for ITEM_LIST in "${LIST_USER[@]}"; do
  STR_CHECK_DIR_PATH="/Users/${ITEM_LIST}/Applications"
  /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH"
  /bin/chmod 700 "$STR_CHECK_DIR_PATH"
  /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/.localized"
  ##サブフォルダを作る
  LIST_SUB_DIR_NAME=("Demos" "Desktop" "Developer" "Documents" "Downloads" "Favorites" "Groups" "Library" "Movies" "Music" "Pictures" "Public" "Shared" "Sites" "System" "Users" "Utilities")
  ##リストの数だけ処理
  for ITEM_DIR_NAME in "${LIST_SUB_DIR_NAME[@]}"; do
    /usr/bin/sudo -u "${ITEM_LIST}" /bin/mkdir -p "$STR_CHECK_DIR_PATH/$ITEM_DIR_NAME"
    /bin/chmod 700 "$STR_CHECK_DIR_PATH/${ITEM_DIR_NAME}"
    /usr/bin/sudo -u "${ITEM_LIST}" /usr/bin/touch "$STR_CHECK_DIR_PATH/$ITEM_DIR_NAME/.localized"
  done
done
########################################
##シンボリックリンクを作る
if [[ ! -e "/Users/$CURRENT_USER/Applications/Applications" ]]; then
  /bin/ln -s "/Applications" "/Users/$CURRENT_USER/Applications/Applications"
fi
if [[ ! -e "/Users/$CURRENT_USER/Applications/Utilities/Finder Applications" ]]; then
  /bin/ln -s "/System/Library/CoreServices/Finder.app/Contents/Applications" "/Users/$CURRENT_USER/Applications/Utilities/Finder Applications"
fi
if [[ ! -e "/Users/$CURRENT_USER/Applications/Utilities/Finder Libraries" ]]; then
  /bin/ln -s "/System/Library/CoreServices/Finder.app/Contents/Resources/MyLibraries" "/Users/$CURRENT_USER/Applications/Utilities/Finder Libraries"
fi
if [[ ! -e "/Users/$CURRENT_USER/Applications/Utilities/System Applications" ]]; then
  /bin/ln -s "/System/Library/CoreServices/Applications" "/Users/$CURRENT_USER/Applications/Utilities/System Applications"
fi
if [[ ! -e "/Users/$CURRENT_USER/Applications/Utilities/System Utilities" ]]; then
  /bin/ln -s "/Applications/Utilities" "/Users/$CURRENT_USER/Applications/Utilities/System Utilities"
fi





#################################
#インストール基本
#################################

STR_URL="https://go.microsoft.com/fwlink/?linkid=823060"

LOCAL_TMP_DIR=$(/usr/bin/sudo -u "$CURRENT_USER" /usr/bin/mktemp -d)
/bin/echo "TMPDIR:" "$LOCAL_TMP_DIR"

###ファイル名を取得
PKG_FILE_NAME=$(/usr/bin/curl -s -L -I -o /dev/null -w '%{url_effective}' "$STR_URL" | /usr/bin/rev | /usr/bin/cut -d'/' -f1 | /usr/bin/rev)
/bin/echo "PKG_FILE_NAME" "$PKG_FILE_NAME"

###ファイル名指定してダウンロード
/usr/bin/sudo -u "$CURRENT_USER" /usr/bin/curl -L -o "$LOCAL_TMP_DIR/$PKG_FILE_NAME" "$STR_URL" --http1.1 --connect-timeout 20

### インストール(上書き)を実行する
/usr/sbin/installer -pkg "$LOCAL_TMP_DIR/$PKG_FILE_NAME" -target / -dumplog -allowUntrusted -lang ja

exit 0


|

[Office]SaveAsAdobePDF.ppam が読み込めませんでした。(修正版)

SaveAsAdobePDF.ppam が読み込めませんでした。
SaveAsAdobePDF.xlam が読み込めませんでした
linkCreation.dotm が読み込めませんでした 対応用

基本的には『リセットツール』を使えば解決できるのですが

Factory Reset Package
Complete Removal Package
Word Reset Package
Excel Reset Package
PowerPoint Reset Package
Outlook Reset Package
Outlook Data Removal Package
OneNote Reset Package
OneDrive Reset Package
Teams Reset Package
Skype For Business Removal Package
AutoUpdate Reset Package
License Reset Package
Zoom Outlook Plugin Removal Package
WebEx Tools Removal Package

https://office-reset.com/
リセットツールはプラグインを削除はしてくれるが、再インストールはしないので

ダウンロード - movetotrashmsjunk.dmg


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.6"
use framework "Foundation"
use scripting additions


property refMe : a reference to current application
set appFileManager to refMe's NSFileManager's defaultManager()

set listBundleID to {"com.microsoft.Powerpoint", "com.microsoft.Word", "com.microsoft.Excel"} as list


################################
#### Cachesリセット
set strBaseDirPath to "~/Library/Caches"
set ocidBaseDirPathStr to refMe's NSString's stringWithString:(strBaseDirPath)
set ocidBaseDirPath to ocidBaseDirPathStr's stringByStandardizingPath()
repeat with itemBundleID in listBundleID
  set strBundleID to itemBundleID as text
  set ocidGoToTrashDirPath to (ocidBaseDirPath's stringByAppendingPathComponent:(strBundleID))
  set boolDone to doMoveToTrash(ocidGoToTrashDirPath)
  log boolDone as boolean
end repeat
################################
#### plistリセット
set strBaseDirPath to "~/Library/Preferences"
set ocidBaseDirPathStr to refMe's NSString's stringWithString:(strBaseDirPath)
set ocidBaseDirPath to ocidBaseDirPathStr's stringByStandardizingPath()
repeat with itemBundleID in listBundleID
  set strBundleID to itemBundleID as text
  set ocidBaseFilePath to (ocidBaseDirPath's stringByAppendingPathComponent:(strBundleID))
  set ocidGoToTrashDirPath to (ocidBaseFilePath's stringByAppendingPathExtension:("plist"))
  set boolDone to doMoveToTrash(ocidGoToTrashDirPath)
  log boolDone as boolean
end repeat
################################
#### Containersリセット
set strBaseDirPath to "~/Library/Containers"
set ocidBaseDirPathStr to refMe's NSString's stringWithString:(strBaseDirPath)
set ocidBaseDirPath to ocidBaseDirPathStr's stringByStandardizingPath()
repeat with itemBundleID in listBundleID
  set strBundleID to itemBundleID as text
  set ocidGoToTrashDirPath to (ocidBaseDirPath's stringByAppendingPathComponent:(strBundleID))
  set boolDone to doMoveToTrash(ocidGoToTrashDirPath)
  log boolDone as boolean
end repeat
################################
#### Application Scriptsリセット
set strBaseDirPath to "~/Library/Application Scripts"
set ocidBaseDirPathStr to refMe's NSString's stringWithString:(strBaseDirPath)
set ocidBaseDirPath to ocidBaseDirPathStr's stringByStandardizingPath()
repeat with itemBundleID in listBundleID
  set strBundleID to itemBundleID as text
  set ocidGoToTrashDirPath to (ocidBaseDirPath's stringByAppendingPathComponent:(strBundleID))
  set boolDone to doMoveToTrash(ocidGoToTrashDirPath)
  log boolDone as boolean
end repeat

################################
#### temporaryDirectory T リセット
set ocidTemporaryDirPathURL to appFileManager's temporaryDirectory
repeat with itemBundleID in listBundleID
  set strBundleID to itemBundleID as text
  set ocidGoToTrashDirPathURL to (ocidTemporaryDirPathURL's URLByAppendingPathComponent:(strBundleID))
  set boolDone to doMoveToTrash(ocidGoToTrashDirPathURL)
  log boolDone as boolean
end repeat

################################
#### temporaryDirectory C リセット
set ocidTemporaryDirPathURL to appFileManager's temporaryDirectory
set ocidContainerDirPathURL to ocidTemporaryDirPathURL's URLByDeletingLastPathComponent()
set ocidCPathURL to ocidContainerDirPathURL's URLByAppendingPathComponent:"C"
repeat with itemBundleID in listBundleID
  set strBundleID to itemBundleID as text
  set ocidGoToTrashDirPathURL to (ocidCPathURL's URLByAppendingPathComponent:(strBundleID))
  set boolDone to doMoveToTrash(ocidGoToTrashDirPathURL)
  log boolDone as boolean
end repeat


################################
###Startup.localized クリーニング
set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Startup.localized/Word/~$nkCreation.dotm"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
set boolDone to doMoveToTrash(ocidFilePathURL)

set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Startup.localized/Excel/~$SaveAsAdobePDF.xlam"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
set boolDone to doMoveToTrash(ocidFilePathURL)


set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Startup.localized/Powerpoint/~$SaveAsAdobePDF.ppam"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
set boolDone to doMoveToTrash(ocidFilePathURL)

################################
###Startup.localized クリーニング
set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Startup.localized/Word/nkCreation.dotm"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
set boolDone to doMoveToTrash(ocidFilePathURL)

set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Startup.localized/Excel/SaveAsAdobePDF.xlam"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
set boolDone to doMoveToTrash(ocidFilePathURL)


set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Startup.localized/Powerpoint/SaveAsAdobePDF.ppam"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
set boolDone to doMoveToTrash(ocidFilePathURL)



################################
####Add-Ins.localized クリーニング
set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Add-Ins.localized/Word/~$nkCreation.dotm"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
set boolDone to doMoveToTrash(ocidFilePathURL)

set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Add-Ins.localized/Excel/~$SaveAsAdobePDF.xlam"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
set boolDone to doMoveToTrash(ocidFilePathURL)

set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Add-Ins.localized/Powerpoint/~$SaveAsAdobePDF.ppam"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
set boolDone to doMoveToTrash(ocidFilePathURL)
################################

set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/mip_policy"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set boolDone to doMoveToTrash(ocidFilePath)
set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/FontCache"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set boolDone to doMoveToTrash(ocidFilePath)
set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/ComRPC32"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set boolDone to doMoveToTrash(ocidFilePath)
set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/TemporaryItems"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set boolDone to doMoveToTrash(ocidFilePath)
set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/MicrosoftRegistrationDB.reg"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set boolDone to doMoveToTrash(ocidFilePath)
set strFilePath to "~/Library/Group Containers/UBF8T346G9.Office/Microsoft Office ACL [English]"
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set boolDone to doMoveToTrash(ocidFilePath)

####新しいファイルをコピーする

set ocidUserShotName to refMe's NSUserName()
set strUserName to ocidUserShotName as text

set strDtomFilePath to "/Library/Application Support/Adobe/MACPDFM/DC/linkCreation.dotm"
set strPpamFilePath to "/Library/Application Support/Adobe/MACPDFM/DC/SaveAsAdobePDF.ppam"
set strXlamFilePath to "/Library/Application Support/Adobe/MACPDFM/DC/SaveAsAdobePDF.xlam"

set strDistDtomFilePath to "/Users/" & strUserName & "/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Startup.localized/Word/linkCreation.dotm"
set strDistPpamFilePath to "/Users/" & strUserName & "/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Startup.localized/Powerpoint/SaveAsAdobePDF.ppam"
set strDistXlamFilePath to "/Users/" & strUserName & "/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Startup.localized/Excel/SaveAsAdobePDF.xlam"


set strCommandText to ("/usr/bin/ditto \"" & strDtomFilePath & "\" \"" & strDistDtomFilePath & "\"") as text
do shell script strCommandText
set strCommandText to ("/usr/bin/ditto \"" & strPpamFilePath & "\" \"" & strDistPpamFilePath & "\"") as text
do shell script strCommandText
set strCommandText to ("/usr/bin/ditto \"" & strXlamFilePath & "\" \"" & strDistXlamFilePath & "\"") as text
do shell script strCommandText

set strCommandText to ("/bin/chmod 755 \"" & strDistDtomFilePath & "\"") as text
do shell script strCommandText
set strCommandText to ("/bin/chmod 755 \"" & strDistPpamFilePath & "\"") as text
do shell script strCommandText
set strCommandText to ("/bin/chmod 755 \"" & strDistXlamFilePath & "\"") as text
do shell script strCommandText



################################
####User Content.localizedを開く
set strDirFilePath to "~/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Startup.localized"
set ocidFilePathStr to refMe's NSString's stringWithString:(strDirFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:true
set appShardWorkspace to refMe's NSWorkspace's sharedWorkspace()
appShardWorkspace's openURL:ocidFilePathURL

################################
####ゴミ箱に入れるサブ
to doMoveToTrash(argFilePath)
  ###ファイルマネジャー初期化
  set appFileManager to refMe's NSFileManager's defaultManager()
  #########################################
  ###渡された値のClassを調べてとりあえずNSURLにする
  set refClass to class of argFilePath
  if refClass is list then
return "エラーリストは処理しません"
  else if refClass is text then
    log "テキストパスです"
    set ocidArgFilePathStr to (refMe's NSString's stringWithString:argFilePath)
    set ocidArgFilePath to ocidArgFilePathStr's stringByStandardizingPath
    set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath)
  else if refClass is alias then
    log "エイリアスパスです"
    set strArgFilePath to (POSIX path of argFilePath) as text
    set ocidArgFilePathStr to (refMe's NSString's stringWithString:strArgFilePath)
    set ocidArgFilePath to ocidArgFilePathStr's stringByStandardizingPath
    set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath)
  else
    set refClass to (className() of argFilePath) as text
    if refClass contains "NSPathStore2" then
      log "NSPathStore2です"
      set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:argFilePath)
    else if refClass contains "NSCFString" then
      log "NSCFStringです"
      set ocidArgFilePath to argFilePath's stringByStandardizingPath
      set ocidArgFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidArgFilePath)
    else if refClass contains "NSURL" then
      set ocidArgFilePathURL to argFilePath
      log "NSURLです"
    end if
  end if
  #########################################
  ###
  -->false
  set ocidFalse to (refMe's NSNumber's numberWithBool:false)'s boolValue
  -->true
  set ocidTrue to (refMe's NSNumber's numberWithBool:true)'s boolValue
  #########################################
  ###NSURLがエイリアス実在するか?
  set ocidArgFilePath to ocidArgFilePathURL's |path|()
  set boolFileAlias to appFileManager's fileExistsAtPath:(ocidArgFilePath)
  log ocidArgFilePath as text
  ###パス先が実在しないなら処理はここまで
  if boolFileAlias = false then
    log "処理中止"
return false
  end if
  #########################################
  ###NSURLがディレクトリなのか?ファイルなのか?
  set listBoolDir to ocidArgFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLIsDirectoryKey) |error|:(reference)
  if (item 2 of listBoolDir) = ocidTrue then
    #########################################
    log "ディレクトリです"
    ##内包リスト
    set listResult to appFileManager's contentsOfDirectoryAtURL:ocidArgFilePathURL includingPropertiesForKeys:{refMe's NSURLPathKey} options:0 |error|:(reference)
    ###結果
    set ocidContentsPathURLArray to item 1 of listResult
    ###リストの数だけ繰り返し
    repeat with itemContentsPathURL in ocidContentsPathURLArray
      ###ゴミ箱に入れる
      set listResult to (appFileManager's trashItemAtURL:itemContentsPathURL resultingItemURL:(missing value) |error|:(reference))
    end repeat
  else
    #########################################
    log "ファイルです"
    ###念のためFilderでも調べる
    tell application "Finder"
      set aliasArgFilePath to ocidArgFilePathURL as alias
      set strPathKind to (kind of aliasArgFilePath) as text
    end tell
    ###/tmpのような特殊フォルダの場合は処理しない
    if strPathKind is "フォルダ" then
return "特殊ディレクトリかシンボリックリンクなので処理しません"
    else
      ###ファイルをゴミ箱に入れる
      set listResult to (appFileManager's trashItemAtURL:ocidArgFilePathURL resultingItemURL:(missing value) |error|:(reference))
    end if
  end if
return true
end doMoveToTrash

|

[Bash]OneDriveアップデート


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

#!/bin/bash
#com.cocolog-nifty.quicktimer.icefloe

########################################
###管理者インストールしているか?チェック
USER_WHOAMI=$(/usr/bin/whoami)
/bin/echo "実行したユーザーは:$USER_WHOAMI"
if [ "$USER_WHOAMI" != "root" ]; then
  /bin/echo "このスクリプトを実行するには管理者権限が必要です。"
  /bin/echo "sudo で実行してください"
  ### path to me
  SCRIPT_PATH="${BASH_SOURCE[0]}"
  /bin/echo "/usr/bin/sudo \"$SCRIPT_PATH\""
  /bin/echo "↑を実行してください"
  exit 1
else
  ###実行しているユーザー名
  SUDO_USER=$(/bin/echo "$HOME" | /usr/bin/awk -F'/' '{print $NF}')
  /bin/echo "実行ユーザー:" "$SUDO_USER"
fi

#################################
#インストール基本
#################################

STR_URL="https://go.microsoft.com/fwlink/?linkid=823060"

LOCAL_TMP_DIR=$(/usr/bin/sudo -u "$SUDO_USER" /usr/bin/mktemp -d)
/bin/echo "TMPDIR:" "$LOCAL_TMP_DIR"

###ファイル名を取得
PKG_FILE_NAME=$(/usr/bin/curl -s -L -I -o /dev/null -w '%{url_effective}' "$STR_URL" | /usr/bin/rev | /usr/bin/cut -d'/' -f1 | /usr/bin/rev)
/bin/echo "PKG_FILE_NAME" "$PKG_FILE_NAME"

###ファイル名指定してダウンロード
/usr/bin/sudo -u "$SUDO_USER" /usr/bin/curl -L -o "$LOCAL_TMP_DIR/$PKG_FILE_NAME" "$STR_URL" --http1.1 --connect-timeout 20

### インストール(上書き)を実行する
/usr/sbin/installer -pkg "$LOCAL_TMP_DIR/$PKG_FILE_NAME" -target / -dumplog -allowUntrusted -lang ja

exit 0


|

その他のカテゴリー

Accessibility Acrobat Acrobat 2020 Acrobat AddOn Acrobat Annotation Acrobat ARMDC Acrobat AV2 Acrobat BookMark Acrobat Classic Acrobat DC Acrobat Dialog Acrobat Distiller Acrobat Form Acrobat JS Acrobat Manifest Acrobat Menu Acrobat Open Acrobat Plugin Acrobat Preferences Acrobat Preflight Acrobat Python Acrobat Reader Acrobat Reader Localized Acrobat Reference Acrobat SCA Acrobat SCA Updater Acrobat Sequ Acrobat Sign Acrobat Stamps Acrobat Watermark Acrobat Windows Acrobat Windows Reader Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Mobileconfig Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin Support Admin System Information Admin Tools Admin Users Admin Volumes Admin XProtect Adobe Adobe Bridge Adobe FDKO Adobe Fonts Adobe Reference Adobe RemoteUpdateManager AppKit Apple AppleScript AppleScript do shell script AppleScript List AppleScript ObjC AppleScript Osax AppleScript PDF AppleScript Pictures AppleScript record AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript System Events AppleScript System Events Plist AppleScript Video Applications AppStore Archive Attributes Automator BackUp Barcode Barcode Decode Barcode QR Bash Basic Basic Path Bluetooth BOX Browser Calendar CD/DVD Choose Chrome CIImage CityCode CloudStorage Color com.apple.LaunchServices.OpenWith Console Contacts CotEditor CURL current application Date&Time defaults delimiters Desktop Device Diff Disk Dock DropBox Droplet eMail Encode % Encode Decode Encode HTML Entity Encode UTF8 Error EXIFData ffmpeg File File Name Finder Firefox Folder FolderAction Fonts Fonts ATS Fonts Python Foxit GIF github Guide HTML Icon Illustrator Image Events Image2PDF ImageOptim Input Dictionary iPhone iWork Javascript Jedit Json Label Language Leading Zero List locationd LRC lsappinfo m3u8 Mail MakePDF Map Math Media Media AVAsset Media AVconvert Media AVFoundation Media AVURLAsset Media Movie Media Music Memo Messages Microsoft Microsoft Edge Microsoft Excel Microsoft Fonts Microsoft Office Mouse Music NetWork Notes NSArray NSArray Sort NSBezierPath NSBitmapImageRep NSBundle NSCFBoolean NSCharacterSet NSColor NSColorList NSData NSDecimalNumber NSDictionary NSError NSEvent NSFileAttributes NSFileManager NSFileManager enumeratorAtURL NSFont NSFontManager NSGraphicsContext NSImage NSIndex NSKeyedArchiver NSKeyedUnarchiver NSLocale NSMetadataItem NSMutableArray NSMutableDictionary NSMutableString NSNotFound NSNumber NSOpenPanel NSPasteboard NSpoint NSPredicate NSPrintOperation NSRange NSRect NSRegularExpression NSRunningApplication NSScreen NSSize NSString NSString stringByApplyingTransform NSStringCompareOptions NSTask NSTimeZone NSURL NSURL File NSURLBookmark NSURLComponents NSURLResourceKey NSURLSession NSUserDefaults NSUUID NSView NSWorkspace Numbers OAuth OneDrive PDF PDF Pymupdf PDFAnnotation PDFAnnotationWidget PDFContext PDFDisplayBox PDFDocumentPermissions PDFImageRep PDFKit PDFnUP PDFOutline perl Photoshop PlistBuddy pluginkit plutil postalcode PostScript prefPane Preview Python QuickLook QuickTime ReadMe Regular Expression Reminders ReName Repeat RTF Safari SaveFile ScreenCapture ScreenSaver SF Symbols character id SF Symbols Entity sips Skype Slack Sound Spotlight sqlite SRT StandardAdditions Swift System Settings TCC TemporaryItems Terminal Text Text CSV Text MD Text TSV TextEdit Tools Translate Trash Twitter Typography UI Unit Conversion UTType valueForKeyPath Video VisionKit Visual Studio Code VMware Fusion Wacom webarchive webp Wifi Windows XML XML EPUB XML HTML XML LSSharedFileList XML OPML XML Plist XML RSS XML savedSearch XML SVG XML TTML XML webloc XML xmllint XML XMP YouTube zoom