Admin Mobileconfig

[NSGlobalDomain_m]AppleLanguages

いつのまにか廃止になった値があるようだ 202411270250381_1064x758
サンプルコード

サンプルソース(参考)
行番号ソース
001<key>AppleLanguages</key>
002<array>
003<string>ja-JP</string>
004<string>en-US</string>
005
006<string>en</string>
007<string>en-JP</string>
008</array>
009<key>AppleLocale</key>
010<string>ja_JP</string>
AppleScriptで生成しました

macOS14で

サンプルコード

サンプルソース(参考)
行番号ソース
001#!/bin/bash
002/usr/bin/defaults read NSGlobalDomain AppleLanguages
003/usr/bin/defaults read -g AppleLanguages
004/usr/bin/defaults read -globalDomain AppleLanguages
AppleScriptで生成しました

NSGlobalDomain_mの値を変更する場合はパス指定がいいようだ
設定は

サンプルコード

サンプルソース(参考)
行番号ソース
001#!/bin/bash
002
003#GlobalPreferences_m
004#設定 現在の設定を削除して作り直し
005LANG_LIST=("ja-JP" "en-US")
006CNT_LANG_LIST=${#LANG_LIST[@]}
007STAT_USR=$(/usr/bin/stat -f%Su /dev/console)
008PATH_PLIST="/Users/${STAT_USR}/Library/Preferences/.GlobalPreferences_m.plist"
009
010if ! /usr/libexec/PlistBuddy -c "Print :AppleLanguages:" "$PATH_PLIST"; then
011  /bin/echo "設定されていません A"
012  for ((ITEMNO = 0; ITEMNO <= (CNT_LANG_LIST - 1); ITEMNO++)); do
013    /usr/libexec/PlistBuddy -c "Add :AppleLanguages:${ITEMNO} string "${LANG_LIST[$ITEMNO]}"" "$PATH_PLIST"
014  done
015else
016  /usr/libexec/PlistBuddy -c "Delete :AppleLanguages" "$PATH_PLIST"
017  for ((ITEMNO = 0; ITEMNO <= (CNT_LANG_LIST - 1); ITEMNO++)); do
018    /usr/libexec/PlistBuddy -c "Add :AppleLanguages:${ITEMNO} string "${LANG_LIST[$ITEMNO]}"" "$PATH_PLIST"
019  done
020fi
021/usr/libexec/PlistBuddy -c "Save" "$PATH_PLIST"
022
023#GlobalPreferences
024#設定 現在の設定を削除して作り直し
025LANG_LIST=("ja-JP" "en-US")
026CNT_LANG_LIST=${#LANG_LIST[@]}
027STAT_USR=$(/usr/bin/stat -f%Su /dev/console)
028PATH_PLIST="/Users/${STAT_USR}/Library/Preferences/.GlobalPreferences.plist"
029
030if ! /usr/libexec/PlistBuddy -c "Print :AppleLanguages:" "$PATH_PLIST"; then
031  /bin/echo "設定されていません A"
032  for ((ITEMNO = 0; ITEMNO <= (CNT_LANG_LIST - 1); ITEMNO++)); do
033    /usr/libexec/PlistBuddy -c "Add :AppleLanguages:${ITEMNO} string "${LANG_LIST[$ITEMNO]}"" "$PATH_PLIST"
034  done
035else
036  /usr/libexec/PlistBuddy -c "Delete :AppleLanguages" "$PATH_PLIST"
037  for ((ITEMNO = 0; ITEMNO <= (CNT_LANG_LIST - 1); ITEMNO++)); do
038    /usr/libexec/PlistBuddy -c "Add :AppleLanguages:${ITEMNO} string "${LANG_LIST[$ITEMNO]}"" "$PATH_PLIST"
039  done
040fi
041/usr/libexec/PlistBuddy -c "Save" "$PATH_PLIST"
042
043
044
045exit 0
AppleScriptで生成しました

|

[com.apple.GlobalPreferences] AppleShowScrollBars


サンプルコード

サンプルソース(参考)
行番号ソース
001基本的には同じ
002/usr/bin/defaults read -g 
003/usr/bin/defaults read -globalDomain 
004/usr/bin/defaults read NSGlobalDomain 
AppleScriptで生成しました

モバイルコンフィグでの記述例
サンプルコード

サンプルソース(参考)
行番号ソース
001<!--
002# WhenScrolling
003# Automatic
004# Always
005-->
006<key>AppleShowScrollBars</key>
007<string>Always</string>
008
009<key>PayloadDescription</key>
010<string>com.apple.NSGlobalDomain</string>
011<key>PayloadDisplayName</key>
012<string>com.apple.GlobalPreferences</string>
013<key>PayloadIdentifier</key>
014<string>.GlobalPreferences.ED0D77FF-2A0E-418B-AC6B-7C79A615D09E</string>
015<key>PayloadType</key>
016<string>.GlobalPreferences</string>
AppleScriptで生成しました

|

[Spotlight]検索キーの追加(mobileconfig)


サンプルコード

サンプルソース(参考)
行番号ソース
001<?xml version="1.0" encoding="UTF-8"?>
002<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
003<plist version="1.0">
004  <dict>
005    <key>ConsentText</key>
006    <dict>
007      <key>default</key>
008      <string>検索設定 Spotlight SlicesRootAttributes</string>
009    </dict>
010    <key>PayloadContent</key>
011    <array>
012      <dict>
013        <key>PayloadDisplayName</key>
014        <string>com.apple.finder.SlicesRootAttributes</string>
015        <key>PayloadIdentifier</key>
016        <string>com.apple.finder.6994FC7C-6CEC-46F9-80B9-527DFD6A6094</string>
017        <key>PayloadType</key>
018        <string>com.apple.finder</string>
019        <key>PayloadUUID</key>
020        <string>6994FC7C-6CEC-46F9-80B9-527DFD6A6094</string>
021        <key>PayloadVersion</key>
022        <integer>20240321</integer>
023        <key>SlicesRootAttributes</key>
024        <array>
025          <string>kMDItemKind</string>
026          <string>kMDItemMediaTypes</string>
027
028          <string>kMDItemLastUsedDate</string>
029          <string>kMDItemContentModificationDate</string>
030          <string>kMDItemContentCreationDate</string>
031          <string>kMDItemFSName</string>
032          <string>kMDItemDisplayName</string>
033          <string>kMDItemTextContent</string>
034          <string>kMDItemFSInvisible</string>
035          <string>kMDItemUserTags</string>
036
037          <string>kMDItemFSSize</string>
038          <string>kMDItemLogicalSize</string>
039
040          <string>kMDItemDurationSeconds</string>
041          <string>kMDItemBitsPerSample</string>
042          <string>kMDItemTotalBitRate</string>
043
044          <string>kMDItemFSLabel</string>
045
046          <string>kMDItemFSContentChangeDate</string>
047          <string>kMDItemFSCreationDate</string>
048          <string>kMDItemEmailAddresses</string>
049
050
051          <string>com_apple_FileExtensionAttribute</string>
052          <string>com_corel_file_applicationname</string>
053
054          <string>kMDItemPhysicalSize</string>
055          <string>kMDItemOrientation</string>
056          <string>kMDItemLayerNames</string>
057          <string>kMDItemPixelCount</string>
058          <string>kMDItemPixelWidth</string>
059          <string>kMDItemPixelHeight</string>
060          <string>kMDItemPageHeight</string>
061          <string>kMDItemPageWidth</string>
062
063          <string>kMDItemColorSpace</string>
064          <string>kMDItemProfileName</string>
065          <string>com_corel_file_document_cmyk_profile</string>
066          <string>com_corel_file_document_colors</string>
067          <string>com_corel_file_document_grayscale_profile</string>
068          <string>com_corel_file_document_palettes</string>
069          <string>com_corel_file_document_rgb_profile</string>
070          <string>com_corel_file_image_colormode</string>
071          <string>com_corel_file_image_colorprofile</string>
072
073          <string>kMDItemAudioBitRate</string>
074          <string>kMDItemAudioChannelCount</string>
075          <string>kMDItemAudioSampleRate</string>
076
077          <string>kMDItemFonts</string>
078          <string>com_apple_ats_name_postscript</string>
079          <string>com_apple_ats_name_family</string>
080          <string>com_apple_ats_name_full</string>
081          <string>com_apple_ats_name_style</string>
082          <string>com_apple_ats_name_fond</string>
083
084
085        </array>
086      </dict>
087    </array>
088    <key>PayloadDescription</key>
089    <string>com.apple.finder.SlicesRootAttributes Version20240321
090      UUID5DA435B7-9F9E-4D44-9090-E78ABE957923</string>
091    <key>PayloadDisplayName</key>
092    <string>com.apple.finder.SlicesRootAttributes</string>
093    <key>PayloadIdentifier</key>
094    <string>com.apple.finder.SlicesRootAttributes.5DA435B7-9F9E-4D44-9090-E78ABE957923</string>
095    <key>PayloadOrganization</key>
096    <string>Organization</string>
097    <key>PayloadScope</key>
098    <string>User</string>
099    <key>PayloadType</key>
100    <string>Configuration</string>
101    <key>PayloadUUID</key>
102    <string>5DA435B7-9F9E-4D44-9090-E78ABE957923</string>
103    <key>PayloadVersion</key>
104    <integer>20240321</integer>
105    <key>TargetDeviceType</key>
106    <integer>5</integer>
107  </dict>
108</plist>
AppleScriptで生成しました

|

[Spotlight]カラースペース関連

20240930123406_1122x906
20240929112441_1840x9842
サンプルコード

サンプルソース(参考)
行番号ソース
001<string>kMDItemColorSpace</string>
002<string>kMDItemProfileName</string>
003<string>com_corel_file_document_cmyk_profile</string>
004<string>com_corel_file_document_colors</string>
005<string>com_corel_file_document_grayscale_profile</string>
006<string>com_corel_file_document_palettes</string>
007<string>com_corel_file_document_rgb_profile</string>
008<string>com_corel_file_image_colormode</string>
009<string>com_corel_file_image_colorprofile</string>
AppleScriptで生成しました

|

com.apple.security Gatekeeperによる抑止の上書き実行許可



要はこの部分

20240928114049_960x454
サンプルコード

サンプルソース(参考)
行番号ソース
001<!-- FALSEで抑止解除して実行OK TRUEで抑止される実行不可-->
002<key>DisableOverride</key>
003<false />
004<key>PayloadDisplayName</key>
005<string>System Policy: Managed</string>
006<key>PayloadType</key>
007<string>com.apple.systempolicy.managed</string>
AppleScriptで生成しました

|

[mobileconfig]com.apple.AssetCache.managed

20240919065416_900x876
サンプルコード

サンプルソース(参考)
行番号ソース
001<?xml version="1.0" encoding="UTF-8"?>
002<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
003<plist version="1.0">
004<dict>
005  <key>PayloadContent</key>
006    <array>
007      <dict>
008        <key>PeerLocalSubnetsOnly</key>
009        <true />
010        <key>LocalSubnetsOnly</key>
011        <true />
012
013        <key>AllowPersonalCaching</key>
014        <false />
015        <key>AllowSharedCaching</key>
016        <false />
017        <key>AutoActivation</key>
018        <false />
019        <key>AutoEnableTetheredCaching</key>
020        <false />
021        <key>CacheLimit</key>
022        <integer>2000000000</integer>
023        <key>DenyTetheredCaching</key>
024        <true />
025        <key>LogClientIdentity</key>
026        <true />
027
028        <key>PayloadDisplayName</key>
029        <string>Content Caching</string>
030        <key>PayloadIdentifier</key>
031        <string>com.apple.AssetCache.managed.C9077E30-2BC6-4E6D-A4C4-0E6F080C6FB1</string>
032        <key>PayloadType</key>
033        <string>com.apple.AssetCache.managed</string>
034        <key>PayloadUUID</key>
035        <string>C9077E30-2BC6-4E6D-A4C4-0E6F080C6FB1</string>
036        <key>PayloadVersion</key>
037        <integer>1</integer>
038
039      </dict>
040    </array>
041  <key>PayloadDisplayName</key>
042  <string>com.apple.AssetCache.managed</string>
043  <key>PayloadIdentifier</key>
044  <string>com.apple.AssetCache.managed.2F76B504-CFD2-40C8-B80E-D3F6BFF349F0</string>
045  <key>PayloadOrganization</key>
046  <string>com.cocolog-nifty.quicktimer</string>
047  <key>PayloadScope</key>
048  <string>System</string>
049  <key>PayloadType</key>
050  <string>Configuration</string>
051  <key>PayloadUUID</key>
052  <string>2F76B504-CFD2-40C8-B80E-D3F6BFF349F0</string>
053  <key>PayloadVersion</key>
054  <integer>1</integer>
055  <key>TargetDeviceType</key>
056  <integer>5</integer>
057</dict>
058</plist>
AppleScriptで生成しました

|

[mobileconfig]com.apple.TextEdit NSFontPanelSizeList

20240917075645_1330x566
NSFontPanelSizeListのみ

ダウンロード - com.apple.textedit.nsfontpanelsizelist.mobileconfig.zip



サンプルコード

サンプルソース(参考)
行番号ソース
001<key>NSFontPanelSizeList</key>
002<array>
003  <string>8</string>
004  <string>9</string>
005  <string>10</string>
006  <string>10.5</string>
007  <string>11</string>
008  <string>12</string>
009  <string>13</string>
010  <string>14</string>
011  <string>18</string>
012  <string>20</string>
013  <string>22</string>
014  <string>24</string>
015  <string>26</string>
016  <string>28</string>
017  <string>32</string>
018  <string>36</string>
019  <string>48</string>
020  <string>52</string>
021  <string>64</string>
022  <string>72</string>
023  <string>96</string>
024  <string>144</string>
025  <string>288</string>
026</array>
AppleScriptで生成しました


フル設定

ダウンロード - com.apple.textedit.mobileconfig.zip


|

[Mobileconfig]フォント貸し出し用のモバイルコンフィグファイルを作成する(有効期限指定)


AppleScript サンプルコード

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

AppleScript サンプルソース(参考)
行番号ソース
001#! /usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004# フォントを提供する場合用の
005# モバイルコンフィグを提供します
006# 使用期限を設定します
007#  com.cocolog-nifty.quicktimer.icefloe
008----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
009use AppleScript version "2.8"
010use framework "Foundation"
011use framework "UniformTypeIdentifiers"
012use framework "AppKit"
013use scripting additions
014property refMe : a reference to current application
015set appFileManager to refMe's NSFileManager's defaultManager()
016
017
018###################################
019# 設定項目
020#PayloadOrganization
021set strPayloadOrganization to ("com.cocolog-nifty.quicktimer")
022#有効期間 X日間有効
023set numPeriodDate to (7) as integer
024
025###################################
026#ダイアログ
027set strName to (name of current application) as text
028if strName is "osascript" then
029  tell application "Finder" to activate
030else
031  tell current application to activate
032end if
033set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
034set ocidLibraryDirPathURL to ocidURLsArray's firstObject()
035set ocidFontsDirPathURL to ocidLibraryDirPathURL's URLByAppendingPathComponent:("Fonts") isDirectory:(true)
036set aliasFontsDirPath to (ocidFontsDirPathURL's absoluteURL()) as alias
037# TTF と OTFのみ コレクションフォントは仕様上の対象外
038set listUTI to {"public.truetype-ttf-font", "public.opentype-font"} as list
039set strMes to ("フォントファイルを選んでください") as text
040set strPrompt to ("フォントファイルを選んでください") as text
041try
042  set aliasFilePath to (choose file strMes with prompt strPrompt default location (aliasFontsDirPath) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias
043on error
044  log "エラーしました"
045  return "エラーしました"
046end try
047##
048set strFilePath to (POSIX path of aliasFilePath) as text
049set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
050set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
051set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
052set ocidFileName to ocidFilePathURL's lastPathComponent()
053set ocidBaseFileName to ocidFileName's stringByDeletingPathExtension()
054
055###################################
056# 保存先
057set appFileManager to refMe's NSFileManager's defaultManager()
058set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
059set ocidDocumentDirPathURL to ocidURLsArray's firstObject()
060set ocidSaveDirPathURL to ocidDocumentDirPathURL's URLByAppendingPathComponent:("Mobileconfig") isDirectory:(true)
061#
062set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
063# 777-->511 755-->493 700-->448 766-->502
064ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
065set listDone to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error| :(reference)
066if (item 1 of listDone) is true then
067  log "createDirectoryAtURL 正常処理"
068else if (item 2 of listDone) ≠ (missing value) then
069  log (item 2 of listDone)'s code() as text
070  log (item 2 of listDone)'s localizedDescription() as text
071  return "createDirectoryAtURL エラーしました"
072end if
073#
074set strSaveFileName to ("com.apple.font." & ocidBaseFileName & ".mobileconfig") as text
075set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(strSaveFileName) isDirectory:(true)
076
077
078###################################
079# NSDataに読み込んで
080set listResponse to refMe's NSData's dataWithContentsOfURL:(ocidFilePathURL) options:(refMe's NSDataWritingAtomic) |error| :(reference)
081if (item 2 of listResponse) = (missing value) then
082  log "dataWithContentsOfURL 正常処理"
083  set ocidReadData to (item 1 of listResponse)
084else if (item 2 of listResponse) ≠ (missing value) then
085  log (item 2 of listResponse)'s code() as text
086  log (item 2 of listResponse)'s localizedDescription() as text
087  return "dataWithContentsOfURL エラーしました"
088end if
089##########################
090#PLIST作成部分
091##########################
092##有効期限
093
094##【ROOT】
095set ocidPlistDict to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
096#
097set ocidSetValue to (5) as integer
098(ocidPlistDict's setValue:(ocidSetValue) forKey:"TargetDeviceType")
099#
100set ocidSetValue to (doGetDateNo("yyyyMMdd")) as integer
101(ocidPlistDict's setValue:(ocidSetValue) forKey:"PayloadVersion")
102#
103set ocidUUID to refMe's NSUUID's alloc()'s init()
104set ocidSetValueUUID to ocidUUID's UUIDString as text
105(ocidPlistDict's setValue:(ocidSetValueUUID) forKey:"PayloadUUID")
106#
107set ocidSetValue to ("User") as text
108(ocidPlistDict's setValue:(ocidSetValue) forKey:"PayloadScope")
109#
110set ocidSetValue to false as boolean
111(ocidPlistDict's setValue:(ocidSetValue) forKey:"PayloadRemovalDisallowed")
112#
113set ocidSetValue to (strPayloadOrganization) as text
114(ocidPlistDict's setValue:(ocidSetValue) forKey:"PayloadOrganization")
115#
116set ocidSetValue to ("Configuration") as text
117(ocidPlistDict's setValue:(ocidSetValue) forKey:"PayloadType")
118#
119set ocidSetValue to ("com.apple.font." & ocidSetValueUUID) as text
120(ocidPlistDict's setValue:(ocidSetValue) forKey:"PayloadIdentifier")
121#
122set ocidSetValue to (strPayloadOrganization & "." & ocidBaseFileName) as text
123(ocidPlistDict's setValue:(ocidSetValue) forKey:"PayloadDisplayName")
124#
125set ocidSetValue to (strPayloadOrganization & "から提供されたフォント\n" & ocidBaseFileName & "になります\n印字・印刷の確認以外の用途での利用を禁止します") as text
126(ocidPlistDict's setValue:(ocidSetValue) forKey:"PayloadDescription")
127#
128set datePeriodDay to doGetPeriodDate(numPeriodDate) as date
129set strPeriodDay to datePeriodDay as text
130set ocidSetDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
131ocidSetDict's setValue:("フォントをインストールします\n期日" & strPeriodDay & "まで\n利用できます\n印字・印刷の確認以外の用途での利用を禁止します") forKey:("default")
132(ocidPlistDict's setObject:(ocidSetDict) forKey:"ConsentText")
133#
134set ocidPeriodDay to doGetPeriodDate(numPeriodDate)
135(ocidPlistDict's setObject:(ocidPeriodDay) forKey:"RemovalDate")
136
137##########################
138##【PayloadContent】
139set ocidPayloadDict to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
140#
141(ocidPayloadDict's setObject:(ocidReadData) forKey:"Font")
142#
143(ocidPayloadDict's setObject:(ocidBaseFileName) forKey:"Name")
144#
145(ocidPayloadDict's setObject:(ocidFileName) forKey:"FileName")
146#
147set ocidSetValue to (doGetDateNo("yyyyMMdd")) as integer
148(ocidPayloadDict's setValue:(ocidSetValue) forKey:"PayloadVersion")
149#
150set ocidUUID to refMe's NSUUID's alloc()'s init()
151set ocidSetValueUUID to ocidUUID's UUIDString as text
152(ocidPayloadDict's setValue:(ocidSetValueUUID) forKey:"PayloadUUID")
153#
154set ocidSetValue to ("com.apple.font") as text
155(ocidPayloadDict's setValue:(ocidSetValue) forKey:"PayloadType")
156#
157set ocidSetValue to ("com.apple.font." & ocidSetValueUUID) as text
158(ocidPayloadDict's setValue:(ocidSetValue) forKey:"PayloadIdentifier")
159#
160set ocidSetValue to ("com.apple.font") as text
161(ocidPayloadDict's setValue:(ocidSetValue) forKey:"PayloadDisplayName")
162#
163set ocidSetValue to (strPayloadOrganization & "から提供されたフォント\n印字・印刷の確認以外の用途での利用を禁止します") as text
164(ocidPayloadDict's setValue:(ocidSetValue) forKey:"PayloadDescription")
165#
166set ocidPayloadArrayM to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
167ocidPayloadArrayM's addObject:(ocidPayloadDict)
168(ocidPlistDict's setObject:(ocidPayloadArrayM) forKey:"PayloadContent")
169
170
171##########################
172#NSPropertyListSerialization
173set ocidFormat to (refMe's NSPropertyListXMLFormat_v1_0)
174set ocidPlistSerial to (refMe's NSPropertyListSerialization)
175set listResponse to (ocidPlistSerial's dataWithPropertyList:(ocidPlistDict) format:(ocidFormat) options:0  |error| :(reference))
176if (item 2 of listResponse) = (missing value) then
177  log "NSPropertyListSerialization 正常処理"
178  set ocidPlistData to (item 1 of listResponse)
179else if (item 2 of listResponse) ≠ (missing value) then
180  log (item 2 of listResponse)'s code() as text
181  log (item 2 of listResponse)'s localizedDescription() as text
182  return "NSPropertyListSerialization エラーしました"
183end if
184##########################
185#保存
186set listDone to (ocidPlistData's writeToURL:(ocidSaveFilePathURL) options:(refMe's NSDataWritingAtomic) |error| :(reference))
187if (item 1 of listDone) is true then
188  log "writeToURL 正常終了"
189else if (item 1 of listDone) is false then
190  return "writeToURL 保存に失敗しました"
191end if
192
193
194###################################
195#保存先を開く
196set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
197set boolDone to appSharedWorkspace's openURL:(ocidSaveDirPathURL)
198if (boolDone) is true then
199  return "openURL 正常処理"
200else
201set aliasSaveDirPath to (ocidSaveDirPathURL's absoluteURL()) as alias
202  tell application "Finder"
203    open folder aliasSaveDirPath
204  end tell
205  return "openURL エラーしました"
206end if
207
208return
209
210
211
212##############################
213### 今の日付日間 テキスト
214##############################
215to doGetDateNo(argDateFormat)
216  ####日付情報の取得
217  set ocidDate to current application's NSDate's |date|()
218  ###日付のフォーマットを定義
219  set ocidNSDateFormatter to current application's NSDateFormatter's alloc()'s init()
220  ocidNSDateFormatter's setLocale:(current application's NSLocale's localeWithLocaleIdentifier:"ja_JP_POSIX")
221  set ocidTimeZone to refMe's NSTimeZone's alloc()'s initWithName:"Asia/Tokyo"
222  ocidNSDateFormatter's setTimeZone:(ocidTimeZone)
223  ocidNSDateFormatter's setDateFormat:(argDateFormat)
224  set ocidDateAndTime to ocidNSDateFormatter's stringFromDate:ocidDate
225  set strDateAndTime to ocidDateAndTime as text
226  return strDateAndTime
227end doGetDateNo
228
229
230##########################
231#有効期間の日付作成
232##########################
233to doGetPeriodDate(argPeriodDateNo)
234  ####今の日付時間
235  set ocidNowDate to refMe's NSDate's |date|()
236  ####カレンダー初期化
237  set ocidNowCalendar to refMe's NSCalendar's alloc()'s initWithCalendarIdentifier:(refMe's NSGregorianCalendar)
238  ####日付時間コンポーネント
239  set ocidDateComponent to refMe's NSDateComponents's alloc()'s init()
240  ####指定の日付を足す
241  ocidDateComponent's setDay:(argPeriodDateNo)
242  ####カレンダーオプション
243  set ocidOption to (refMe's NSCalendarWrapComponents)
244  ####今のカレンダーにコンポーネント分の値を追加する
245  set ocidPeriodDate to ocidNowCalendar's dateByAddingComponents:ocidDateComponent toDate:ocidNowDate options:ocidOption
246  return ocidPeriodDate
247end doGetPeriodDate
AppleScriptで生成しました

|

[mobileconfig]フォントデータを書き出す


AppleScript サンプルコード

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

AppleScript サンプルソース(参考)
行番号ソース
001#! /usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003(*
004com.cocolog-nifty.quicktimer.icefloe
005モバイルコンフィグのフォントデータを取り出して
006ファイルに保存します。
007利用には、取り出したフォントに対しての利用許諾が必要です
008詳しくはモバイルコンフィグを作成した方にお問い合わせください
009*)
010----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
011use AppleScript version "2.8"
012use framework "Foundation"
013use framework "AppKit"
014use scripting additions
015
016property refMe : a reference to current application
017
018
019###################################
020#ダイアログ
021set strName to (name of current application) as text
022if strName is "osascript" then
023  tell application "Finder" to activate
024else
025  tell current application to activate
026end if
027set aliasDefaultLocation to (path to desktop from user domain) as alias
028set listUTI to {"com.apple.mobileconfig"} as list
029set strPromptText to "ファイルをえらんでください" as text
030set strMesText to "ファイルをえらんでください" as text
031try
032  set aliasFilePath to (choose file strMesText with prompt strPromptText default location aliasDefaultLocation of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias
033on error
034  log "エラーしました"
035  return "エラーしました"
036end try
037#入力パス
038set strFilePath to (POSIX path of aliasFilePath) as text
039set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
040set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
041set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
042###################################
043# 保存先
044set appFileManager to refMe's NSFileManager's defaultManager()
045set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
046set ocidDocumentDirPathURL to ocidURLsArray's firstObject()
047set ocidSaveDirPathURL to ocidDocumentDirPathURL's URLByAppendingPathComponent:("Library/Fonts") isDirectory:(true)
048#
049set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
050# 777-->511 755-->493 700-->448 766-->502
051ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
052set listDone to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error| :(reference)
053if (item 1 of listDone) is true then
054  log "createDirectoryAtURL 正常処理"
055else if (item 2 of listDone) ≠ (missing value) then
056  log (item 2 of listDone)'s code() as text
057  log (item 2 of listDone)'s localizedDescription() as text
058  return "createDirectoryAtURL エラーしました"
059end if
060
061###################################
062# NSDataに読み込んで
063set listResponse to refMe's NSData's dataWithContentsOfURL:(ocidFilePathURL) options:(refMe's NSDataWritingAtomic) |error| :(reference)
064if (item 2 of listResponse) = (missing value) then
065  log "dataWithContentsOfURL 正常処理"
066  set ocidReadData to (item 1 of listResponse)
067else if (item 2 of listResponse) ≠ (missing value) then
068  log (item 2 of listResponse)'s code() as text
069  log (item 2 of listResponse)'s localizedDescription() as text
070  return "dataWithContentsOfURL エラーしました"
071end if
072
073###################################
074# NSDICT NSPropertyListSerialization
075set ocidXmlPlist to (refMe's NSPropertyListXMLFormat_v1_0)
076set ocidPlistSerial to (refMe's NSPropertyListSerialization)
077set ocidOption to (refMe's NSPropertyListMutableContainersAndLeaves)
078set listResponse to ocidPlistSerial's propertyListWithData:(ocidReadData) options:(ocidOption) format:(ocidXmlPlist) |error| :(reference)
079if (item 2 of listResponse) = (missing value) then
080  log "NSPropertyListSerialization 正常処理"
081  set ocidPlistDict to (item 1 of listResponse)
082else if (item 2 of listResponse) ≠ (missing value) then
083  log (item 2 of listResponse)'s code() as text
084  log (item 2 of listResponse)'s localizedDescription() as text
085  return "NSPropertyListSerialization エラーしました"
086end if
087
088###################################
089# データの取得
090set ocidPayloadArray to ocidPlistDict's objectForKey:("PayloadContent")
091repeat with itemPayload in ocidPayloadArray
092  set ocidFontFileName to (itemPayload's objectForKey:("Name"))
093  set ocidFontData to (itemPayload's objectForKey:("Font"))
094  #OTFなのか?TTFなのか?判定しておく
095  set ocidOption to (refMe's NSDataBase64Encoding64CharacterLineLength)
096  set ocidFontDataBse64 to (ocidFontData's base64EncodedStringWithOptions:(ocidOption))
097  set boolOTF to (ocidFontDataBse64's hasPrefix:("T1RUTw"))
098  set boolTTF to (ocidFontDataBse64's hasPrefix:("AAEAAA"))
099  #保存ファイルパス
100  set ocidBaseFilePathURL to (ocidSaveDirPathURL's URLByAppendingPathComponent:(ocidFontFileName) isDirectory:(false))
101  #拡張子指定
102  if boolOTF is true then
103    set ocidSaveFilePathURL to (ocidBaseFilePathURL's URLByAppendingPathExtension:("otf"))
104  else if boolTTF is true then
105    set ocidSaveFilePathURL to (ocidBaseFilePathURL's URLByAppendingPathExtension:("ttf"))
106  end if
107  ##保存
108  set listDone to (ocidFontData's writeToURL:(ocidSaveFilePathURL) options:(refMe's NSDataWritingAtomic) |error| :(reference))
109  if (item 1 of listDone) is true then
110    log "writeToURL 正常終了"
111  else if (item 1 of listDone) is false then
112    return "writeToURL 保存に失敗しました"
113  end if
114end repeat
115
116
117###################################
118#保存先を開く
119set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
120set boolDone to appSharedWorkspace's openURL:(ocidSaveDirPathURL)
121if (boolDone) is true then
122  return "openURL 正常処理"
123else
124  return "openURL エラーしました"
125end if
126
AppleScriptで生成しました

|

[mobileconfig] mobileconfigファイルをVisual Studio Codeで開きます(ドロップレット)


あくまでも参考にしてください

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

サンプルソース(参考)
行番号ソース
001#! /usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004# mobileconfigをVS CODEで開きます
005#com.cocolog-nifty.quicktimer.icefloe
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use framework "Foundation"
009use framework "AppKit"
010use scripting additions
011
012property refMe : a reference to current application
013
014
015on run
016  ###ダイアログを前面に出す
017  set strName to (name of current application) as text
018  if strName is "osascript" then
019    tell application "Finder" to activate
020  else
021    tell current application to activate
022  end if
023  # デフォルトロケーション
024  set appFileManager to refMe's NSFileManager's defaultManager()
025  set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
026  set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
027  set aliasDesktopDirPath to (ocidDesktopDirPathURL's absoluteURL()) as alias
028  set listUTI to {"com.apple.mobileconfig"} as list
029  set strMes to ("mobileconfigをドロップしてください") as text
030  set strPrompt to ("mobileconfigをドロップしてください") as text
031  try
032    ### ファイル選択時
033    set aliasFilePath to (choose file strMes with prompt strPrompt default location (aliasDesktopDirPath) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias
034  on error
035    log "エラーしました"
036    return "エラーしました"
037  end try
038  
039  open aliasFilePath
040end run
041
042on open argAliasFilePath
043  ##パス
044  set aliasFilePath to argAliasFilePath as alias
045  set strFilePath to (POSIX path of aliasFilePath) as text
046  set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
047  set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
048  set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
049  #
050  set listResponse to (ocidFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLContentTypeKey) |error| :(reference))
051  # listResponseは{boolean,VALUE,NSERROR}のリスト形式
052  if (item 1 of listResponse) is (true) then
053    set ocidUTType to (item 2 of listResponse)
054    set strUTI to ocidUTType's identifier() as text
055    if strUTI is "com.apple.mobileconfig" then
056      log "処理します"
057      set aliasFilePath to (ocidFilePathURL's absoluteURL()) as alias
058      set strFilePath to (ocidFilePathURL's |path|()) as text
059    else
060      return "com.apple.mobileconfigをドロップしてください"
061    end if
062  else if (item 1 of listResponse) is (false) then
063    log (item 3 of listResponse)'s code() as text
064    log (item 3 of listResponse)'s localizedDescription() as text
065    return "com.apple.mobileconfigをドロップしてください"
066  end if
067    
068  try
069    tell application "System Events"
070      tell application id "com.microsoft.VSCode"
071        open aliasFilePath
072      end tell
073    end tell
074  on error
075    try
076      set theCmdCom to ("open -a  \"Visual Studio Code\"  \"" & theFilePath & "\"") as text
077      do shell script theCmdCom
078    on error
079      set theCmdCom to ("open -b  \"com.microsoft.VSCode\"  \"" & theFilePath & "\"") as text
080      do shell script theCmdCom
081    end try
082  end try
083  
084end open
085
086
AppleScriptで生成しました

|

より以前の記事一覧

その他のカテゴリー

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 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 Adobe Adobe FDKO 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 QR Barcode QR Decode 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 delimiters Desktop Device Diff Disk Dock DropBox Droplet eMail Encode % Encode Decode Encode UTF8 Error EXIFData ffmpeg File Finder Firefox Folder FolderAction Fonts GIF github Guide HTML HTML Entity Icon Illustrator Image Events Image2PDF ImageOptim iPhone iWork Javascript Jedit Json Label Leading Zero List locationd LRC lsappinfo LSSharedFileList 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 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 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 PDFAnnotation PDFAnnotationWidget PDFContext PDFDisplayBox PDFDocumentPermissions PDFImageRep PDFKit PDFnUP PDFOutline perl Photoshop PlistBuddy pluginkit 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 OPML XML Plist XML RSS XML savedSearch XML SVG XML TTML XML webloc XML XMP YouTube zoom