20260323

【設定】NSDisableAutomaticTermination


【設定】NSDisableAutomaticTermination をTRUE =AutomaticTermination しないようにする


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

【設定】AutomaticTermination.scpt
ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003(* 
004AutomaticTerminationの設定を変更します
005
0061:GlobalPreferences
0072:com.apple.Preview の設定で
008AutomaticTerminationが無効にします
009
010AutomaticTerminationについては
011https://note.com/quicktimer/n/n43da194743c9
012
013
014設定終了後は
015ログアウトーログイン
016又は
017デバイスの電源OFFーONをしてはじめて適応されます
018
019
020com.cocolog-nifty.quicktimer.icefloe *)
021----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
022use AppleScript version "2.8"
023use framework "Foundation"
024use framework "AppKit"
025use framework "UniformTypeIdentifiers"
026use scripting additions
027
028property refMe : a reference to current application
029
030tell application id "com.apple.Preview" to quit
031###########
032#NSGlobalDomain
033set strCmd to ("/usr/bin/defaults read NSGlobalDomain NSDisableAutomaticTermination") as text
034set strStdOut to (do shell script strCmd) as text
035if strStdOut is "0" then
036   set strCmd to ("/usr/bin/defaults write -globalDomain NSDisableAutomaticTermination -bool true") as text
037   set strStdOut to (do shell script strCmd) as text
038end if
039delay 0.25
040set strCmd to ("/usr/bin/defaults read NSGlobalDomain NSDisableAutomaticTermination") as text
041set strStdOut to (do shell script strCmd) as text
042if strStdOut is "0" then
043   log "NSGlobalDomainの設定が変更できませんでした:0"
044else if strStdOut is "1" then
045   log "NSGlobalDomainの設定が正しく変更されました:1"
046end if
047###########
048#com.apple.Preview
049set strCmd to ("/usr/bin/defaults read com.apple.Preview NSDisableAutomaticTermination") as text
050set strStdOut to (do shell script strCmd) as text
051if strStdOut is "0" then
052   set strCmd to ("/usr/bin/defaults write com.apple.Preview NSDisableAutomaticTermination -bool true") as text
053   set strStdOut to (do shell script strCmd) as text
054end if
055delay 0.25
056set strCmd to ("/usr/bin/defaults read com.apple.Preview NSDisableAutomaticTermination") as text
057set strStdOut to (do shell script strCmd) as text
058if strStdOut is "0" then
059   log "NSGlobalDomainの設定が変更できませんでした:0"
060else if strStdOut is "1" then
061   log "NSGlobalDomainの設定が正しく変更されました:1"
062end if
063
064
065return
AppleScriptで生成しました