Admin configCode

[ConfigCode]NSLocale情報が必須に変更(モデル名の取得)

モデル名の取得に必要なConfigCode
20237月12日現在
ConfigCodeの取得『support-sp.apple.com』について
クエリーでlangが必須に変更になった
https://support-sp.apple.com/sp/product?cc=XXXXで取得できたモデル名が
https://support-sp.apple.com/sp/product?cc=XXXX&lang=(localeIdentifier)

localeIdentifierが必須に変更になった

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

#!/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 "AppKit"
use scripting additions

property refMe : a reference to current application


###初期化
set appNSWorkspace to refMe's NSWorkspace's sharedWorkspace()
set appFileManager to refMe's NSFileManager's defaultManager()
#####ダイアログを前面に
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
###ダイアログ
set listUTI to {"com.apple.application-bundle"}
###アプリケーションディレクトリ
set ocidUserLibraryPathArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationDirectory) inDomains:(refMe's NSUserDomainMask))
###URL
set ocidAppDirPathURL to ocidUserLibraryPathArray's firstObject()
set aliaAppDirPath to (ocidAppDirPathURL's absoluteURL()) as alias
set aliasAppPath to (choose file with prompt "対象のアプリケーションを選んでください" default location (aliaAppDirPath) of type listUTI with invisibles without showing package contents and multiple selections allowed) as alias
###パス
set strAppPath to POSIX path of aliasAppPath
set ocidAppPathStr to refMe's NSString's stringWithString:(strAppPath)
set ocidAppPath to ocidAppPathStr's stringByStandardizingPath()
set ocidAppPathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidAppPath) isDirectory:true)
#####################################
######ファイル保存先
#####################################
set ocidUserLibraryPathArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidFilePathURL to ocidUserLibraryPathArray's objectAtIndex:0
set ocidSaveDirPathURL to ocidFilePathURL's URLByAppendingPathComponent:"Apple/IOPlatformUUID"
############################
#####属性
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
############################
###フォルダを作る
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
#####################################
###### enrollment チェック
#####################################
set strEnrollment to (do shell script "/usr/bin/profiles status -type enrollment") as text
set strCsrutil to (do shell script "/usr/bin/csrutil status") as text
set strSpctl to (do shell script "/bin/echo \"$(/usr/sbin/spctl --verbose --status)\"") as text
#####################################
###### ioreg PLIST
#####################################
set ocidIoregFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:"ioreg.plist"
###古いファイルはゴミ箱に
set boolResults to (appFileManager's trashItemAtURL:(ocidIoregFilePathURL) resultingItemURL:(missing value) |error|:(reference))
#####################################
set strCommandText to "/usr/sbin/ioreg -c IOPlatformExpertDevice -a " as text
set strPlistData to (do shell script strCommandText) as text
###戻り値をストリングに
set ocidPlistStrings to refMe's NSString's stringWithString:(strPlistData)
###NSDATAにして
set ocidPlisStringstData to ocidPlistStrings's dataUsingEncoding:(refMe's NSUTF8StringEncoding)
###ファイルに書き込み(使い回し用)-->不要な場合は削除して
ocidPlisStringstData's writeToURL:(ocidIoregFilePathURL) atomically:true

###PLIST初期化して
set listResults to refMe's NSPropertyListSerialization's propertyListWithData:ocidPlisStringstData options:0 format:(refMe's NSPropertyListXMLFormat_v1_0) |error|:(reference)
###各種値を取得する NSSingleObjectArray に留意
set ocidPlistDataArray to item 1 of listResults
set ocidDeviceUUIDArray to (ocidPlistDataArray's valueForKeyPath:"IORegistryEntryChildren.IOPlatformUUID")
set ocidDeviceUUID to ocidDeviceUUIDArray's firstObject()
set ocidDeviceSerialNumberArray to (ocidPlistDataArray's valueForKeyPath:"IORegistryEntryChildren.IOPlatformSerialNumber")
set ocidDeviceSerialNumber to ocidDeviceSerialNumberArray's firstObject()
set ocidDeviceEntryNameArray to (ocidPlistDataArray's valueForKeyPath:"IORegistryEntryChildren.IORegistryEntryName")
set ocidDeviceEntryName to ocidDeviceEntryNameArray's firstObject()
###モデル名はNSDATAなのでテキストに解凍する
set ocidModelArray to (ocidPlistDataArray's valueForKeyPath:("IORegistryEntryChildren.model"))
set ocidModel to ocidModelArray's firstObject()
###まぁエラーになるとは思えないが
if (className() of ocidModel as text) is "NSNull" then
  set strCommandText to ("/usr/sbin/sysctl -n hw.model") as text
  set strModelStr to (do shell script strCommandText) as text
else
  set ocidModelStr to refMe's NSString's alloc()'s initWithData:(ocidModel) encoding:(refMe's NSUTF8StringEncoding)
  set strModelStr to ocidModelStr as text
end if
#####################################
######サポート情報取得
#####################################
###バンドル
set ocidAppBundle to refMe's NSBundle's bundleWithURL:(ocidAppPathURL)
set strFilePath to ocidAppPathURL's |path|() as text

###基本情報を取得
set ocidInfoDict to ocidAppBundle's infoDictionary
###PLISTのURLを取得して
# set ocidPlistPathURL to ocidAppBundlePathURL's URLByAppendingPathComponent:("Contents/Info.plist") isDirectory:false
###読み込む
#set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidPlistPathURL)
set ocidBundleName to ocidInfoDict's valueForKey:("CFBundleName")
set ocidBundleExecutable to ocidInfoDict's valueForKey:("CFBundleExecutable")
set ocidBundleDisplayName to ocidInfoDict's valueForKey:("CFBundleDisplayName")

set ocidBundleVersion to ocidInfoDict's valueForKey:("CFBundleVersion")
set ocidBuild to ocidInfoDict's valueForKey:("DTSDKBuild")
set ocidShortVersionString to ocidInfoDict's valueForKey:("CFBundleShortVersionString")
###クローム用
set ocidChannelID to ocidInfoDict's valueForKey:("KSChannelID")
###Acrobat用
set ocidTrackName to ocidInfoDict's valueForKey:("TrackName")

#####################################
###### diskutil PLIST
#####################################
set ocidDiskutilFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:"diskutil.plist"
###古いファイルはゴミ箱に
set boolResults to (appFileManager's trashItemAtURL:(ocidDiskutilFilePathURL) resultingItemURL:(missing value) |error|:(reference))
#####################################
set strCommandText to "/usr/sbin/diskutil info -plist /" as text
set strPlistData to (do shell script strCommandText) as text
###戻り値をストリングに
set ocidPlistStrings to refMe's NSString's stringWithString:(strPlistData)
###NSDATAにして
set ocidPlisStringstData to ocidPlistStrings's dataUsingEncoding:(refMe's NSUTF8StringEncoding)
###ファイルに書き込み(使い回し用)-->不要な場合は削除して
ocidPlisStringstData's writeToURL:(ocidDiskutilFilePathURL) atomically:true
###PLIST初期化して
set listResults to refMe's NSPropertyListSerialization's propertyListWithData:ocidPlisStringstData options:0 format:(refMe's NSPropertyListXMLFormat_v1_0) |error|:(reference)
###各種値を取得する NSSingleObjectArray に留意
set ocidPlistDataArray to item 1 of listResults
###ボリューム名 他
set ocidVolumeName to (ocidPlistDataArray's valueForKey:"VolumeName")
set ocidDiskUUID to (ocidPlistDataArray's valueForKey:"DiskUUID")
set ocidVolumeUUID to (ocidPlistDataArray's valueForKey:"VolumeUUID")
set ocidFilesystemName to (ocidPlistDataArray's valueForKey:"FilesystemName")
set ocidFileVault to (ocidPlistDataArray's valueForKey:"FileVault")
set ocidEncryption to (ocidPlistDataArray's valueForKey:"Encryption")
###サイズ
set ocidTotalSize to (ocidPlistDataArray's valueForKey:"TotalSize")
set intGB to "1073741824" as integer
set ocidGB to (refMe's NSNumber's numberWithInteger:intGB)
set intTotalSize to ((ocidTotalSize's doubleValue as real) / (ocidGB's doubleValue as real)) as integer
###残
set ocidAPFSContainerFree to (ocidPlistDataArray's valueForKey:"APFSContainerFree")
set intGB to "1073741824" as integer
set ocidGB to (refMe's NSNumber's numberWithInteger:intGB)
set intContainerFree to ((ocidAPFSContainerFree's doubleValue as real) / (ocidGB's doubleValue as real)) as integer
########################
##メモリサイズを調べる
set ocidProcessInfo to refMe's NSProcessInfo's processInfo()
set realMemoryByte to ocidProcessInfo's physicalMemory() as real
set realGB to "1073741824" as real
set intPhysicalMemory to realMemoryByte / realGB as integer
##ユーザー情報
set ocidEnvDict to ocidProcessInfo's environment()
set strHOME to (ocidEnvDict's valueForKey:"HOME") as text
set strUSER to (ocidEnvDict's valueForKey:"USER") as text
set strLOGNAME to (ocidEnvDict's valueForKey:"LOGNAME") as text
set strTMPDIR to (ocidEnvDict's valueForKey:"TMPDIR") as text
########################
###OSのバージョン
set ocidSystemPathArray to (appFileManager's URLsForDirectory:(refMe's NSCoreServiceDirectory) inDomains:(refMe's NSSystemDomainMask))
set ocidCoreServicePathURL to ocidSystemPathArray's firstObject()
set ocidPlistFilePathURL to ocidCoreServicePathURL's URLByAppendingPathComponent:"SystemVersion.plist"
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidPlistFilePathURL)
set strOSversion to (ocidPlistDict's valueForKey:("ProductVersion")) as text
########################
###configCodeにする(後ろから4文字)
set intTextlength to (ocidDeviceSerialNumber's |length|) as integer
set ocidRenge to refMe's NSMakeRange((intTextlength - 4), 4)
set strConfigCode to (ocidDeviceSerialNumber's substringWithRange:(ocidRenge)) as text
###モデル名を取得 configCode
set strURL to "https://support-sp.apple.com/sp/product"
set ocidURLStr to refMe's NSString's stringWithString:(strURL)
set ocidURL to refMe's NSURL's URLWithString:(ocidURLStr)
####コンポーネント
set ocidComponents to refMe's NSURLComponents's alloc()'s initWithURL:(ocidURL) resolvingAgainstBaseURL:false
set ocidComponentArray to refMe's NSMutableArray's alloc()'s initWithCapacity:0
##
set ocidQueryItem to refMe's NSURLQueryItem's alloc()'s initWithName:("cc") value:(strConfigCode)
ocidComponentArray's addObject:(ocidQueryItem)
##
set ocidLocale to refMe's NSLocale's currentLocale()
set ocidLocaleID to ocidLocale's localeIdentifier()
set ocidQueryItem to (refMe's NSURLQueryItem's alloc()'s initWithName:("lang") value:(ocidLocaleID))
(ocidComponentArray's addObject:(ocidQueryItem))
###検索クエリーとして追加
(ocidComponents's setQueryItems:(ocidComponentArray))
####コンポーネントをURLに展開
set ocidNewURL to ocidComponents's |URL|()
log ocidNewURL's absoluteString() as text
###XML読み込み
set ocidOption to (refMe's NSXMLDocumentTidyXML)
set listReadXMLDoc to refMe's NSXMLDocument's alloc()'s initWithContentsOfURL:(ocidNewURL) options:(ocidOption) |error|:(reference)
set ocidReadXMLDoc to (item 1 of listReadXMLDoc)



###ROOTエレメント
set ocidRootElement to ocidReadXMLDoc's rootElement()
###configCodeからモデル名を取得
set ocidConfigCode to ocidRootElement's elementsForName:"configCode"
set strConfigCode to ocidConfigCode's stringValue as text
####CPUタイプ
set strCPU to CPU type of (system info) as text

########################
###ダイアログ
set strIconPath to "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/FinderIcon.icns" as text
set aliasIconPath to POSIX file strIconPath as alias

set strAns to ("デバイス型番:" & ocidDeviceEntryName & "\r") as text
set strAns to (strAns & "モデル番号:" & strModelStr & "\r") as text
set strAns to (strAns & "モデル名:" & strConfigCode & "\r") as text
set strAns to (strAns & "※デバイスUUID:" & ocidDeviceUUID & "\r") as text
set strAns to (strAns & "※シリアル番号:" & ocidDeviceSerialNumber & "\r") as text
set strAns to (strAns & "OSバージョン:" & strOSversion & "\r") as text
set strAns to (strAns & "CPU:" & strCPU & "\r") as text
set strAns to (strAns & "----+----1----+----2----+-----3----+----4----+----5\r") as text
set strAns to (strAns & "※enrollment:" & strEnrollment & "\r") as text
set strAns to (strAns & "csrutil:" & strCsrutil & "\r") as text
set strAns to (strAns & "spctl:" & strSpctl & "\r") as text
set strAns to (strAns & "----+----1----+----2----+-----3----+----4----+----5\r") as text
set strAns to (strAns & "起動ボリューム名:" & ocidVolumeName & "\r") as text
set strAns to (strAns & "※ディスクUUID:" & ocidDiskUUID & "\r") as text
set strAns to (strAns & "※ボリュームUUID:" & ocidVolumeUUID & "\r") as text
set strAns to (strAns & "ファイルシステム:" & ocidFilesystemName & "\r") as text
set strAns to (strAns & "FileVault:" & ocidFileVault & "\r") as text
set strAns to (strAns & "暗号化:" & ocidEncryption & "\r") as text
set strAns to (strAns & "ディスクサイズ:" & intTotalSize & " GB\r") as text
set strAns to (strAns & "ディスク残:" & intContainerFree & " GB\r") as text
set strAns to (strAns & "物理メモリ:" & intPhysicalMemory & " GB\r") as text
set strAns to (strAns & "----+----1----+----2----+-----3----+----4----+----5\r") as text
set strAns to (strAns & "ホーム:" & strHOME & "\r") as text
set strAns to (strAns & "ユーザー名:" & strUSER & "\r") as text
set strAns to (strAns & "ログイン名:" & strLOGNAME & "\r") as text
set strAns to (strAns & "※テンポラリ:" & strTMPDIR & "\r") as text
set strAns to (strAns & "----+----1----+----2----+-----3----+----4----+----5\r") as text
set strAns to (strAns & "CFBundleName:" & ocidBundleName & "\r") as text
set strAns to (strAns & "CFBundleExecutable:" & ocidBundleExecutable & "\r") as text
set strAns to (strAns & "CFBundleDisplayName:" & ocidBundleDisplayName & "\r") as text
set strAns to (strAns & "CFBundleVersion:" & ocidBundleVersion & "\r") as text
set strAns to (strAns & "DTSDKBuild:" & ocidBuild & "\r") as text
set strAns to (strAns & "ShortVersion:" & ocidShortVersionString & "\r") as text
set strAns to (strAns & "KSChannelID:" & ocidChannelID & "\r") as text
set strAns to (strAns & "TrackName:" & ocidTrackName & "\r") as text
set strAns to (strAns & "インストールパス:" & strFilePath & "\r") as text


#####ダイアログを前面に
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if

###ダイアログ
set recordResult to (display dialog "ioreg 戻り値です\rコピーしてメールかメッセージを送ってください\r※相手が信用出来ない場合は削除" with title "モデル番号" default answer strAns buttons {"クリップボードにコピー", "キャンセル", "OK"} default button "OK" giving up after 30 with icon aliasIconPath without hidden answer)
###クリップボードコピー
if button returned of recordResult is "クリップボードにコピー" then
  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)
end if

|

[tool]サポートに必要な情報を取得する(BLOGや掲示板に公開用) 修正あり


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

#!/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 "AppKit"
use scripting additions
property refMe : a reference to current application


set strLocale to "ja_JP"


###初期化
set appFileManager to refMe's NSFileManager's defaultManager()
#####ダイアログを前面に
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
###ダイアログ
set listUTI to {"com.apple.application-bundle"}
###アプリケーションディレクトリ
set ocidUserLibraryPathArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationDirectory) inDomains:(refMe's NSUserDomainMask))
###URL
set ocidAppDirPathURL to ocidUserLibraryPathArray's firstObject()
set aliaAppDirPath to (ocidAppDirPathURL's absoluteURL()) as alias
set aliasAppPath to (choose file with prompt "対象のアプリケーションを選んでください" default location (aliaAppDirPath) of type listUTI with invisibles without showing package contents and multiple selections allowed) as alias
###パス
set strAppPath to POSIX path of aliasAppPath
set ocidAppPathStr to refMe's NSString's stringWithString:(strAppPath)
set ocidAppPath to ocidAppPathStr's stringByStandardizingPath()
set ocidAppPathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidAppPath) isDirectory:true)

#####################################
######ファイル保存先
#####################################
set ocidUserLibraryPathArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidFilePathURL to ocidUserLibraryPathArray's firstObject()
set ocidSaveDirPathURL to ocidFilePathURL's URLByAppendingPathComponent:"Apple/IOPlatformUUID"
############################
#####属性
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
############################
###フォルダを作る
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
#####################################
###### ioreg PLIST
#####################################
set ocidIoregFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:"ioreg.plist"
###古いファイルはゴミ箱に
set boolResults to (appFileManager's trashItemAtURL:(ocidIoregFilePathURL) resultingItemURL:(missing value) |error|:(reference))
#####################################
set strCommandText to "/usr/sbin/ioreg -c IOPlatformExpertDevice -a " as text
set strPlistData to (do shell script strCommandText) as text
###戻り値をストリングに
set ocidPlistStrings to refMe's NSString's stringWithString:(strPlistData)
###NSDATAにして
set ocidPlisStringstData to ocidPlistStrings's dataUsingEncoding:(refMe's NSUTF8StringEncoding)
###ファイルに書き込み(使い回し用)-->不要な場合は削除して
ocidPlisStringstData's writeToURL:(ocidIoregFilePathURL) atomically:true

###PLIST初期化して
set listResults to refMe's NSPropertyListSerialization's propertyListWithData:ocidPlisStringstData options:0 format:(refMe's NSPropertyListXMLFormat_v1_0) |error|:(reference)
###各種値を取得する NSSingleObjectArray に留意
set ocidPlistDataArray to item 1 of listResults
set ocidDeviceUUIDArray to (ocidPlistDataArray's valueForKeyPath:"IORegistryEntryChildren.IOPlatformUUID")
set ocidDeviceUUID to ocidDeviceUUIDArray's firstObject()
set ocidDeviceSerialNumberArray to (ocidPlistDataArray's valueForKeyPath:"IORegistryEntryChildren.IOPlatformSerialNumber")
set ocidDeviceSerialNumber to ocidDeviceSerialNumberArray's firstObject()
set ocidDeviceEntryNameArray to (ocidPlistDataArray's valueForKeyPath:"IORegistryEntryChildren.IORegistryEntryName")
set ocidDeviceEntryName to ocidDeviceEntryNameArray's firstObject()
###モデル名はNSDATAなのでテキストに解凍する
set ocidModelArray to (ocidPlistDataArray's valueForKeyPath:("IORegistryEntryChildren.model"))
set ocidModel to ocidModelArray's firstObject()
###まぁエラーになるとは思えないが
if (className() of ocidModel as text) is "NSNull" then
  set strCommandText to ("/usr/sbin/sysctl -n hw.model") as text
  set strModelStr to (do shell script strCommandText) as text
else
  set ocidModelStr to refMe's NSString's alloc()'s initWithData:(ocidModel) encoding:(refMe's NSUTF8StringEncoding)
  set strModelStr to ocidModelStr as text
end if
#####################################
######サポート情報取得
#####################################
set ocidAppBundle to refMe's NSBundle's bundleWithURL:(ocidAppPathURL)
###基本情報を取得
set ocidInfoDict to ocidAppBundle's infoDictionary
###PLISTのURLを取得して
# set ocidPlistPathURL to ocidAppBundlePathURL's URLByAppendingPathComponent:("Contents/Info.plist") isDirectory:false
###読み込む
#set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidPlistPathURL)
set ocidBundleName to ocidInfoDict's valueForKey:("CFBundleName")
set ocidBundleExecutable to ocidInfoDict's valueForKey:("CFBundleExecutable")
set ocidBundleDisplayName to ocidInfoDict's valueForKey:("CFBundleDisplayName")

set ocidBundleVersion to ocidInfoDict's valueForKey:("CFBundleVersion")
set ocidBuild to ocidInfoDict's valueForKey:("DTSDKBuild")
set ocidShortVersionString to ocidInfoDict's valueForKey:("CFBundleShortVersionString")
###クローム用
set ocidChannelID to ocidInfoDict's valueForKey:("KSChannelID")
###Acrobat用
set ocidTrackName to ocidInfoDict's valueForKey:("TrackName")

#####################################
###### diskutil PLIST
#####################################
set ocidDiskutilFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:"diskutil.plist"
###古いファイルはゴミ箱に
set boolResults to (appFileManager's trashItemAtURL:(ocidDiskutilFilePathURL) resultingItemURL:(missing value) |error|:(reference))
#####################################
set strCommandText to "/usr/sbin/diskutil info -plist /" as text
set strPlistData to (do shell script strCommandText) as text
###戻り値をストリングに
set ocidPlistStrings to refMe's NSString's stringWithString:(strPlistData)
###NSDATAにして
set ocidPlisStringstData to ocidPlistStrings's dataUsingEncoding:(refMe's NSUTF8StringEncoding)
###ファイルに書き込み(使い回し用)-->不要な場合は削除して
ocidPlisStringstData's writeToURL:(ocidDiskutilFilePathURL) atomically:true
###PLIST初期化して
set listResults to refMe's NSPropertyListSerialization's propertyListWithData:ocidPlisStringstData options:0 format:(refMe's NSPropertyListXMLFormat_v1_0) |error|:(reference)
###各種値を取得する NSSingleObjectArray に留意
set ocidPlistDataArray to item 1 of listResults
###ボリューム名 他
set ocidVolumeName to (ocidPlistDataArray's valueForKey:"VolumeName")
set ocidDiskUUID to (ocidPlistDataArray's valueForKey:"DiskUUID")
set ocidVolumeUUID to (ocidPlistDataArray's valueForKey:"VolumeUUID")
set ocidFilesystemName to (ocidPlistDataArray's valueForKey:"FilesystemName")
set ocidFileVault to (ocidPlistDataArray's valueForKey:"FileVault")
set ocidEncryption to (ocidPlistDataArray's valueForKey:"Encryption")
###サイズ
set ocidTotalSize to (ocidPlistDataArray's valueForKey:"TotalSize")
set intGB to "1073741824" as integer
set ocidGB to (refMe's NSNumber's numberWithInteger:intGB)
set intTotalSize to ((ocidTotalSize's doubleValue as real) / (ocidGB's doubleValue as real)) as integer
###残
set ocidAPFSContainerFree to (ocidPlistDataArray's valueForKey:"APFSContainerFree")
set intGB to "1073741824" as integer
set ocidGB to (refMe's NSNumber's numberWithInteger:intGB)
set intContainerFree to ((ocidAPFSContainerFree's doubleValue as real) / (ocidGB's doubleValue as real)) as integer
########################
##メモリサイズを調べる
set ocidProcessInfo to refMe's NSProcessInfo's processInfo()
set realMemoryByte to ocidProcessInfo's physicalMemory() as real
set realGB to "1073741824" as real
set intPhysicalMemory to realMemoryByte / realGB as integer
##ユーザー情報
set ocidEnvDict to ocidProcessInfo's environment()
set strHOME to (ocidEnvDict's valueForKey:"HOME") as text
set strUSER to (ocidEnvDict's valueForKey:"USER") as text
set strLOGNAME to (ocidEnvDict's valueForKey:"LOGNAME") as text
set strTMPDIR to (ocidEnvDict's valueForKey:"TMPDIR") as text
########################
###OSのバージョン
set ocidSystemPathArray to (appFileManager's URLsForDirectory:(refMe's NSCoreServiceDirectory) inDomains:(refMe's NSSystemDomainMask))
set ocidCoreServicePathURL to ocidSystemPathArray's firstObject()
set ocidPlistFilePathURL to ocidCoreServicePathURL's URLByAppendingPathComponent:"SystemVersion.plist"
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidPlistFilePathURL)
set strOSversion to (ocidPlistDict's valueForKey:("ProductVersion")) as text
########################
###configCodeにする(後ろから4文字)
set intTextlength to (ocidDeviceSerialNumber's |length|) as integer
set ocidRenge to refMe's NSMakeRange((intTextlength - 4), 4)
set strConfigCode to (ocidDeviceSerialNumber's substringWithRange:(ocidRenge)) as text
###モデル名を取得 configCode
set strURL to "https://support-sp.apple.com/sp/product"
set ocidURLStr to refMe's NSString's stringWithString:(strURL)
set ocidURL to refMe's NSURL's URLWithString:(ocidURLStr)
####コンポーネント
set ocidComponents to refMe's NSURLComponents's alloc()'s initWithURL:(ocidURL) resolvingAgainstBaseURL:false
set ocidComponentArray to refMe's NSMutableArray's alloc()'s initWithCapacity:0
##JSON指定
set ocidQueryItem to refMe's NSURLQueryItem's alloc()'s initWithName:("cc") value:(strConfigCode)
ocidComponentArray's addObject:(ocidQueryItem)
#####アーティスト名から artist idを取得する
set ocidQueryItem to (refMe's NSURLQueryItem's alloc()'s initWithName:("lang") value:(strLocale))
(ocidComponentArray's addObject:(ocidQueryItem))
###検索クエリーとして追加
(ocidComponents's setQueryItems:(ocidComponentArray))
####コンポーネントをURLに展開
set ocidNewURL to ocidComponents's |URL|()
log ocidNewURL's absoluteString() as text

###XML読み込み
set ocidOption to (refMe's NSXMLDocumentTidyXML)
set listReadXMLDoc to refMe's NSXMLDocument's alloc()'s initWithContentsOfURL:(ocidNewURL) options:(ocidOption) |error|:(reference)
set ocidReadXMLDoc to (item 1 of listReadXMLDoc)
###ROOTエレメント
set ocidRootElement to ocidReadXMLDoc's rootElement()
###configCodeからモデル名を取得
set ocidConfigCode to ocidRootElement's elementsForName:"configCode"
set strConfigCode to ocidConfigCode's stringValue as text
####CPUタイプ
set strCPU to CPU type of (system info) as text
log strConfigCode as text

########################
###ダイアログ
set strIconPath to "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/FinderIcon.icns" as text
set aliasIconPath to POSIX file strIconPath as alias


set strAns to ("モデル名:" & strConfigCode & "\r") as text
set strAns to (strAns & "OSバージョン:" & strOSversion & "\r") as text
set strAns to (strAns & "物理メモリ:" & intPhysicalMemory & " GB\r") as text
set strAns to (strAns & "CFBundleExecutable:" & ocidBundleExecutable & "\r") as text
set strAns to (strAns & "ShortVersion:" & ocidShortVersionString & "\r") as text



#####ダイアログを前面に
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if

###ダイアログ
set recordResult to (display dialog "ioreg 戻り値です\rコピーしてメールかメッセージを送ってください\r※相手が信用出来ない場合は削除" with title "モデル番号" default answer strAns buttons {"クリップボードにコピー", "キャンセル", "OK"} default button "OK" giving up after 30 with icon aliasIconPath without hidden answer)
###クリップボードコピー
if button returned of recordResult is "クリップボードにコピー" then
  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)
end if

|

[configCode]モデル名を取得する

コピーできるようにした

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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#モデル名を取得します
#例:"MacBook Pro (13-inch, M1, 2020)"
# BaseURL https://checkcoverage.apple.com
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application

set appFileManager to refMe's NSFileManager's defaultManager()
#################################################
######ファイル保存先 書類>>Apple >> IOPlatformUUID
#################################################
set ocidUserLibraryPathArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidFilePathURL to ocidUserLibraryPathArray's objectAtIndex:0
set ocidSaveDirPathURL to ocidFilePathURL's URLByAppendingPathComponent:"Apple/IOPlatformUUID"
############################
#####属性
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
############################
###フォルダを作る
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
#####################################
######PLISTパス
#####################################
set ocidFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:"ioreg.plist"
set strFilePath to (ocidFilePathURL's |path|()) as text
###古いファイルはゴミ箱に
set boolResults to (appFileManager's trashItemAtURL:ocidFilePathURL resultingItemURL:(missing value) |error|:(reference))

#####################################
set strCommandText to "/usr/sbin/ioreg -c IOPlatformExpertDevice -a " as text
set strPlistData to (do shell script strCommandText) as text
###戻り値をストリングに
set ocidPlistStrings to refMe's NSString's stringWithString:strPlistData
###NSDATAにして
set ocidPlisStringstData to ocidPlistStrings's dataUsingEncoding:(refMe's NSUTF8StringEncoding)
###ファイルに書き込み(使い回し用)-->不要な場合は削除して
ocidPlisStringstData's writeToURL:ocidFilePathURL atomically:true
###PLIST初期化して
set listResults to refMe's NSPropertyListSerialization's propertyListWithData:(ocidPlisStringstData) options:0 format:(refMe's NSPropertyListXMLFormat_v1_0) |error|:(reference)
###シリアル番号を取得する
set ocidPlistDataArray to item 1 of listResults
set ocidDeviceSerialNumberArray to (ocidPlistDataArray's valueForKeyPath:"IORegistryEntryChildren.IOPlatformSerialNumber")
set ocidDeviceSerialNumber to ocidDeviceSerialNumberArray's firstObject()
###configCodeにする(後ろから4文字)
set intTextlength to (ocidDeviceSerialNumber's |length|) as integer
set ocidRenge to refMe's NSMakeRange((intTextlength - 4), 4)
set strConfigCode to (ocidDeviceSerialNumber's substringWithRange:(ocidRenge)) as text

###################################################
######URLを整形する
set strURL to "https://support-sp.apple.com/sp/product"
set ocidURLStr to refMe's NSString's stringWithString:(strURL)
set ocidURL to refMe's NSURL's URLWithString:(ocidURLStr)
###コンフィグコードでクエリーを設定
set strQueryItem to ("cc=" & strConfigCode) as text
set ocidComponents to refMe's NSURLComponents's alloc()'s initWithURL:(ocidURL) resolvingAgainstBaseURL:false
ocidComponents's setQuery:(strQueryItem)
###URLにして
set ocidNewURL to ocidComponents's |URL|()
log ocidNewURL's absoluteString() as text
###XML読み込み
set ocidOption to (refMe's NSXMLDocumentTidyXML)
set listReadXMLDoc to refMe's NSXMLDocument's alloc()'s initWithContentsOfURL:(ocidNewURL) options:(ocidOption) |error|:(reference)
set ocidReadXMLDoc to (item 1 of listReadXMLDoc)
###ROOTエレメント
set ocidRootElement to ocidReadXMLDoc's rootElement()
###子要素の数
set numCntChild to ocidRootElement's childCount() as integer
###第一階層だけの子要素
repeat with numCntChild from 0 to (numCntChild - 1)
  log (ocidRootElement's childAtIndex:numCntChild)'s |name| as text
  log (ocidRootElement's childAtIndex:numCntChild)'s stringValue as text
end repeat
set ocidConfigCode to ocidRootElement's elementsForName:"configCode"
log ocidConfigCode's stringValue as text



################################
######ダイアログ
################################
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder"
    activate
  end tell
else
  tell current application
    activate
  end tell
end if

set aliasIconPath to POSIX file "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/com.apple.imac-g4-20.icns" as alias
try
  set recordResponse to (display dialog "モデル名です" with title "モデル名" default answer (ocidConfigCode's stringValue as text) buttons {"クリップボードにコピー", "OK", "キャンセル"} default button "OK" cancel button "キャンセル" with icon aliasIconPath giving up after 20 without hidden answer)
  
on error
  log "エラーしました"
return "エラーしました"
end try
if true is equal to (gave up of recordResponse) then
return "時間切れですやりなおしてください"
end if
if "OK" is equal to (button returned of recordResponse) then
  set strResponse to (text returned of recordResponse) as text
else if button returned of recordResponse is "クリップボードにコピー" then
  set strText to text returned of recordResponse 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)
return
else
  log "キャンセルしました"
return "キャンセルしました"
end if


return (ocidConfigCode's stringValue as text)

|

[tool]サポートに必要な情報を取得する(基本情報+対象アプリ) 追加

enrollmentの有無とセキュリティ情報を追加

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

#!/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 "AppKit"
use scripting additions

property refMe : a reference to current application


###初期化
set appNSWorkspace to refMe's NSWorkspace's sharedWorkspace()
set appFileManager to refMe's NSFileManager's defaultManager()
#####ダイアログを前面に
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
###ダイアログ
set listUTI to {"com.apple.application-bundle"}
###アプリケーションディレクトリ
set ocidUserLibraryPathArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationDirectory) inDomains:(refMe's NSUserDomainMask))
###URL
set ocidAppDirPathURL to ocidUserLibraryPathArray's firstObject()
set aliaAppDirPath to (ocidAppDirPathURL's absoluteURL()) as alias
set aliasAppPath to (choose file with prompt "対象のアプリケーションを選んでください" default location (aliaAppDirPath) of type listUTI with invisibles without showing package contents and multiple selections allowed) as alias
###パス
set strAppPath to POSIX path of aliasAppPath
set ocidAppPathStr to refMe's NSString's stringWithString:(strAppPath)
set ocidAppPath to ocidAppPathStr's stringByStandardizingPath()
set ocidAppPathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidAppPath) isDirectory:true)
#####################################
######ファイル保存先
#####################################
set ocidUserLibraryPathArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidFilePathURL to ocidUserLibraryPathArray's objectAtIndex:0
set ocidSaveDirPathURL to ocidFilePathURL's URLByAppendingPathComponent:"Apple/IOPlatformUUID"
############################
#####属性
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
############################
###フォルダを作る
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
#####################################
###### enrollment チェック
#####################################
set strEnrollment to (do shell script "/usr/bin/profiles status -type enrollment") as text
set strCsrutil to (do shell script "/usr/bin/csrutil status") as text
set strSpctl to (do shell script "/bin/echo \"$(/usr/sbin/spctl --verbose --status)\"") as text
#####################################
###### ioreg PLIST
#####################################
set ocidIoregFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:"ioreg.plist"
###古いファイルはゴミ箱に
set boolResults to (appFileManager's trashItemAtURL:(ocidIoregFilePathURL) resultingItemURL:(missing value) |error|:(reference))
#####################################
set strCommandText to "/usr/sbin/ioreg -c IOPlatformExpertDevice -a " as text
set strPlistData to (do shell script strCommandText) as text
###戻り値をストリングに
set ocidPlistStrings to refMe's NSString's stringWithString:(strPlistData)
###NSDATAにして
set ocidPlisStringstData to ocidPlistStrings's dataUsingEncoding:(refMe's NSUTF8StringEncoding)
###ファイルに書き込み(使い回し用)-->不要な場合は削除して
ocidPlisStringstData's writeToURL:(ocidIoregFilePathURL) atomically:true

###PLIST初期化して
set listResults to refMe's NSPropertyListSerialization's propertyListWithData:ocidPlisStringstData options:0 format:(refMe's NSPropertyListXMLFormat_v1_0) |error|:(reference)
###各種値を取得する NSSingleObjectArray に留意
set ocidPlistDataArray to item 1 of listResults
set ocidDeviceUUIDArray to (ocidPlistDataArray's valueForKeyPath:"IORegistryEntryChildren.IOPlatformUUID")
set ocidDeviceUUID to ocidDeviceUUIDArray's firstObject()
set ocidDeviceSerialNumberArray to (ocidPlistDataArray's valueForKeyPath:"IORegistryEntryChildren.IOPlatformSerialNumber")
set ocidDeviceSerialNumber to ocidDeviceSerialNumberArray's firstObject()
set ocidDeviceEntryNameArray to (ocidPlistDataArray's valueForKeyPath:"IORegistryEntryChildren.IORegistryEntryName")
set ocidDeviceEntryName to ocidDeviceEntryNameArray's firstObject()
###モデル名はNSDATAなのでテキストに解凍する
set ocidModelArray to (ocidPlistDataArray's valueForKeyPath:("IORegistryEntryChildren.model"))
set ocidModel to ocidModelArray's firstObject()
###まぁエラーになるとは思えないが
if (className() of ocidModel as text) is "NSNull" then
  set strCommandText to ("/usr/sbin/sysctl -n hw.model") as text
  set strModelStr to (do shell script strCommandText) as text
else
  set ocidModelStr to refMe's NSString's alloc()'s initWithData:(ocidModel) encoding:(refMe's NSUTF8StringEncoding)
  set strModelStr to ocidModelStr as text
end if
#####################################
######サポート情報取得
#####################################
###バンドル
set ocidAppBundle to refMe's NSBundle's bundleWithURL:(ocidAppPathURL)
set strFilePath to ocidAppPathURL's |path|() as text

###基本情報を取得
set ocidInfoDict to ocidAppBundle's infoDictionary
###PLISTのURLを取得して
# set ocidPlistPathURL to ocidAppBundlePathURL's URLByAppendingPathComponent:("Contents/Info.plist") isDirectory:false
###読み込む
#set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidPlistPathURL)
set ocidBundleName to ocidInfoDict's valueForKey:("CFBundleName")
set ocidBundleExecutable to ocidInfoDict's valueForKey:("CFBundleExecutable")
set ocidBundleDisplayName to ocidInfoDict's valueForKey:("CFBundleDisplayName")

set ocidBundleVersion to ocidInfoDict's valueForKey:("CFBundleVersion")
set ocidBuild to ocidInfoDict's valueForKey:("DTSDKBuild")
set ocidShortVersionString to ocidInfoDict's valueForKey:("CFBundleShortVersionString")
###クローム用
set ocidChannelID to ocidInfoDict's valueForKey:("KSChannelID")
###Acrobat用
set ocidTrackName to ocidInfoDict's valueForKey:("TrackName")

#####################################
###### diskutil PLIST
#####################################
set ocidDiskutilFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:"diskutil.plist"
###古いファイルはゴミ箱に
set boolResults to (appFileManager's trashItemAtURL:(ocidDiskutilFilePathURL) resultingItemURL:(missing value) |error|:(reference))
#####################################
set strCommandText to "/usr/sbin/diskutil info -plist /" as text
set strPlistData to (do shell script strCommandText) as text
###戻り値をストリングに
set ocidPlistStrings to refMe's NSString's stringWithString:(strPlistData)
###NSDATAにして
set ocidPlisStringstData to ocidPlistStrings's dataUsingEncoding:(refMe's NSUTF8StringEncoding)
###ファイルに書き込み(使い回し用)-->不要な場合は削除して
ocidPlisStringstData's writeToURL:(ocidDiskutilFilePathURL) atomically:true
###PLIST初期化して
set listResults to refMe's NSPropertyListSerialization's propertyListWithData:ocidPlisStringstData options:0 format:(refMe's NSPropertyListXMLFormat_v1_0) |error|:(reference)
###各種値を取得する NSSingleObjectArray に留意
set ocidPlistDataArray to item 1 of listResults
###ボリューム名 他
set ocidVolumeName to (ocidPlistDataArray's valueForKey:"VolumeName")
set ocidDiskUUID to (ocidPlistDataArray's valueForKey:"DiskUUID")
set ocidVolumeUUID to (ocidPlistDataArray's valueForKey:"VolumeUUID")
set ocidFilesystemName to (ocidPlistDataArray's valueForKey:"FilesystemName")
set ocidFileVault to (ocidPlistDataArray's valueForKey:"FileVault")
set ocidEncryption to (ocidPlistDataArray's valueForKey:"Encryption")
###サイズ
set ocidTotalSize to (ocidPlistDataArray's valueForKey:"TotalSize")
set intGB to "1073741824" as integer
set ocidGB to (refMe's NSNumber's numberWithInteger:intGB)
set intTotalSize to ((ocidTotalSize's doubleValue as real) / (ocidGB's doubleValue as real)) as integer
###残
set ocidAPFSContainerFree to (ocidPlistDataArray's valueForKey:"APFSContainerFree")
set intGB to "1073741824" as integer
set ocidGB to (refMe's NSNumber's numberWithInteger:intGB)
set intContainerFree to ((ocidAPFSContainerFree's doubleValue as real) / (ocidGB's doubleValue as real)) as integer
########################
##メモリサイズを調べる
set ocidProcessInfo to refMe's NSProcessInfo's processInfo()
set realMemoryByte to ocidProcessInfo's physicalMemory() as real
set realGB to "1073741824" as real
set intPhysicalMemory to realMemoryByte / realGB as integer
##ユーザー情報
set ocidEnvDict to ocidProcessInfo's environment()
set strHOME to (ocidEnvDict's valueForKey:"HOME") as text
set strUSER to (ocidEnvDict's valueForKey:"USER") as text
set strLOGNAME to (ocidEnvDict's valueForKey:"LOGNAME") as text
set strTMPDIR to (ocidEnvDict's valueForKey:"TMPDIR") as text
########################
###OSのバージョン
set ocidSystemPathArray to (appFileManager's URLsForDirectory:(refMe's NSCoreServiceDirectory) inDomains:(refMe's NSSystemDomainMask))
set ocidCoreServicePathURL to ocidSystemPathArray's firstObject()
set ocidPlistFilePathURL to ocidCoreServicePathURL's URLByAppendingPathComponent:"SystemVersion.plist"
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidPlistFilePathURL)
set strOSversion to (ocidPlistDict's valueForKey:("ProductVersion")) as text
########################
###configCodeにする(後ろから4文字)
set intTextlength to (ocidDeviceSerialNumber's |length|) as integer
set ocidRenge to refMe's NSMakeRange((intTextlength - 4), 4)
set strConfigCode to (ocidDeviceSerialNumber's substringWithRange:(ocidRenge)) as text
###モデル名を取得 configCode
set strURL to "https://support-sp.apple.com/sp/product"
set ocidURLStr to refMe's NSString's stringWithString:(strURL)
set ocidURL to refMe's NSURL's URLWithString:(ocidURLStr)
###コンフィグコードでクエリーを設定
##コンポーネントをURLで初期化
set ocidComponents to refMe's NSURLComponents's alloc()'s initWithURL:(ocidURL) resolvingAgainstBaseURL:false
##setQueryの場合
# set strQueryItem to ("cc=" & strConfigCode) as text
# ocidComponents's setQuery:(strQueryItem)
###setQueryItemsの場合
set ocidQueryItem to refMe's NSURLQueryItem's alloc()'s initWithName:("cc") value:(strConfigCode)
ocidComponents's setQueryItems:({ocidQueryItem})
###URLにして
set ocidNewURL to ocidComponents's |URL|()
###XML読み込み
set ocidOption to (refMe's NSXMLDocumentTidyXML)
set listReadXMLDoc to refMe's NSXMLDocument's alloc()'s initWithContentsOfURL:(ocidNewURL) options:(ocidOption) |error|:(reference)
set ocidReadXMLDoc to (item 1 of listReadXMLDoc)
###ROOTエレメント
set ocidRootElement to ocidReadXMLDoc's rootElement()
###configCodeからモデル名を取得
set ocidConfigCode to ocidRootElement's elementsForName:"configCode"
set strConfigCode to ocidConfigCode's stringValue as text
####CPUタイプ
set strCPU to CPU type of (system info) as text

########################
###ダイアログ
set strIconPath to "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/FinderIcon.icns" as text
set aliasIconPath to POSIX file strIconPath as alias

set strAns to ("デバイス型番:" & ocidDeviceEntryName & "\r") as text
set strAns to (strAns & "モデル番号:" & strModelStr & "\r") as text
set strAns to (strAns & "モデル名:" & strConfigCode & "\r") as text
set strAns to (strAns & "※デバイスUUID:" & ocidDeviceUUID & "\r") as text
set strAns to (strAns & "※シリアル番号:" & ocidDeviceSerialNumber & "\r") as text
set strAns to (strAns & "OSバージョン:" & strOSversion & "\r") as text
set strAns to (strAns & "CPU:" & strCPU & "\r") as text
set strAns to (strAns & "----+----1----+----2----+-----3----+----4----+----5\r") as text
set strAns to (strAns & "※enrollment:" & strEnrollment & "\r") as text
set strAns to (strAns & "csrutil:" & strCsrutil & "\r") as text
set strAns to (strAns & "spctl:" & strSpctl & "\r") as text
set strAns to (strAns & "----+----1----+----2----+-----3----+----4----+----5\r") as text
set strAns to (strAns & "起動ボリューム名:" & ocidVolumeName & "\r") as text
set strAns to (strAns & "※ディスクUUID:" & ocidDiskUUID & "\r") as text
set strAns to (strAns & "※ボリュームUUID:" & ocidVolumeUUID & "\r") as text
set strAns to (strAns & "ファイルシステム:" & ocidFilesystemName & "\r") as text
set strAns to (strAns & "FileVault:" & ocidFileVault & "\r") as text
set strAns to (strAns & "暗号化:" & ocidEncryption & "\r") as text
set strAns to (strAns & "ディスクサイズ:" & intTotalSize & " GB\r") as text
set strAns to (strAns & "ディスク残:" & intContainerFree & " GB\r") as text
set strAns to (strAns & "物理メモリ:" & intPhysicalMemory & " GB\r") as text
set strAns to (strAns & "----+----1----+----2----+-----3----+----4----+----5\r") as text
set strAns to (strAns & "ホーム:" & strHOME & "\r") as text
set strAns to (strAns & "ユーザー名:" & strUSER & "\r") as text
set strAns to (strAns & "ログイン名:" & strLOGNAME & "\r") as text
set strAns to (strAns & "※テンポラリ:" & strTMPDIR & "\r") as text
set strAns to (strAns & "----+----1----+----2----+-----3----+----4----+----5\r") as text
set strAns to (strAns & "CFBundleName:" & ocidBundleName & "\r") as text
set strAns to (strAns & "CFBundleExecutable:" & ocidBundleExecutable & "\r") as text
set strAns to (strAns & "CFBundleDisplayName:" & ocidBundleDisplayName & "\r") as text
set strAns to (strAns & "CFBundleVersion:" & ocidBundleVersion & "\r") as text
set strAns to (strAns & "DTSDKBuild:" & ocidBuild & "\r") as text
set strAns to (strAns & "ShortVersion:" & ocidShortVersionString & "\r") as text
set strAns to (strAns & "KSChannelID:" & ocidChannelID & "\r") as text
set strAns to (strAns & "TrackName:" & ocidTrackName & "\r") as text
set strAns to (strAns & "インストールパス:" & strFilePath & "\r") as text


#####ダイアログを前面に
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if

###ダイアログ
set recordResult to (display dialog "ioreg 戻り値です\rコピーしてメールかメッセージを送ってください\r※相手が信用出来ない場合は削除" with title "モデル番号" default answer strAns buttons {"クリップボードにコピー", "キャンセル", "OK"} default button "OK" giving up after 30 with icon aliasIconPath without hidden answer)
###クリップボードコピー
if button returned of recordResult is "クリップボードにコピー" then
  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)
end if

|

[tool]サポートに必要な情報を取得する(BLOGや掲示板に公開用)

[tool]サポートに必要な情報を取得する(基本情報+対象アプリ)の
表示項目を減らしただけ

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

#!/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 "AppKit"
use scripting additions
property refMe : a reference to current application


set strLocale to "ja_JP"


###初期化
set appFileManager to refMe's NSFileManager's defaultManager()
#####ダイアログを前面に
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
###ダイアログ
set listUTI to {"com.apple.application-bundle"}
###アプリケーションディレクトリ
set ocidUserLibraryPathArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationDirectory) inDomains:(refMe's NSUserDomainMask))
###URL
set ocidAppDirPathURL to ocidUserLibraryPathArray's firstObject()
set aliaAppDirPath to (ocidAppDirPathURL's absoluteURL()) as alias
set aliasAppPath to (choose file with prompt "対象のアプリケーションを選んでください" default location (aliaAppDirPath) of type listUTI with invisibles without showing package contents and multiple selections allowed) as alias
###パス
set strAppPath to POSIX path of aliasAppPath
set ocidAppPathStr to refMe's NSString's stringWithString:(strAppPath)
set ocidAppPath to ocidAppPathStr's stringByStandardizingPath()
set ocidAppPathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidAppPath) isDirectory:true)

#####################################
######ファイル保存先
#####################################
set ocidUserLibraryPathArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidFilePathURL to ocidUserLibraryPathArray's firstObject()
set ocidSaveDirPathURL to ocidFilePathURL's URLByAppendingPathComponent:"Apple/IOPlatformUUID"
############################
#####属性
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
############################
###フォルダを作る
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
#####################################
###### ioreg PLIST
#####################################
set ocidIoregFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:"ioreg.plist"
###古いファイルはゴミ箱に
set boolResults to (appFileManager's trashItemAtURL:(ocidIoregFilePathURL) resultingItemURL:(missing value) |error|:(reference))
#####################################
set strCommandText to "/usr/sbin/ioreg -c IOPlatformExpertDevice -a " as text
set strPlistData to (do shell script strCommandText) as text
###戻り値をストリングに
set ocidPlistStrings to refMe's NSString's stringWithString:(strPlistData)
###NSDATAにして
set ocidPlisStringstData to ocidPlistStrings's dataUsingEncoding:(refMe's NSUTF8StringEncoding)
###ファイルに書き込み(使い回し用)-->不要な場合は削除して
ocidPlisStringstData's writeToURL:(ocidIoregFilePathURL) atomically:true

###PLIST初期化して
set listResults to refMe's NSPropertyListSerialization's propertyListWithData:ocidPlisStringstData options:0 format:(refMe's NSPropertyListXMLFormat_v1_0) |error|:(reference)
###各種値を取得する NSSingleObjectArray に留意
set ocidPlistDataArray to item 1 of listResults
set ocidDeviceUUIDArray to (ocidPlistDataArray's valueForKeyPath:"IORegistryEntryChildren.IOPlatformUUID")
set ocidDeviceUUID to ocidDeviceUUIDArray's firstObject()
set ocidDeviceSerialNumberArray to (ocidPlistDataArray's valueForKeyPath:"IORegistryEntryChildren.IOPlatformSerialNumber")
set ocidDeviceSerialNumber to ocidDeviceSerialNumberArray's firstObject()
set ocidDeviceEntryNameArray to (ocidPlistDataArray's valueForKeyPath:"IORegistryEntryChildren.IORegistryEntryName")
set ocidDeviceEntryName to ocidDeviceEntryNameArray's firstObject()
###モデル名はNSDATAなのでテキストに解凍する
set ocidModelArray to (ocidPlistDataArray's valueForKeyPath:("IORegistryEntryChildren.model"))
set ocidModel to ocidModelArray's firstObject()
###まぁエラーになるとは思えないが
if (className() of ocidModel as text) is "NSNull" then
  set strCommandText to ("/usr/sbin/sysctl -n hw.model") as text
  set strModelStr to (do shell script strCommandText) as text
else
  set ocidModelStr to refMe's NSString's alloc()'s initWithData:(ocidModel) encoding:(refMe's NSUTF8StringEncoding)
  set strModelStr to ocidModelStr as text
end if
#####################################
######サポート情報取得
#####################################
set ocidAppBundle to refMe's NSBundle's bundleWithURL:(ocidAppPathURL)
###基本情報を取得
set ocidInfoDict to ocidAppBundle's infoDictionary
###PLISTのURLを取得して
# set ocidPlistPathURL to ocidAppBundlePathURL's URLByAppendingPathComponent:("Contents/Info.plist") isDirectory:false
###読み込む
#set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidPlistPathURL)
set ocidBundleName to ocidInfoDict's valueForKey:("CFBundleName")
set ocidBundleExecutable to ocidInfoDict's valueForKey:("CFBundleExecutable")
set ocidBundleDisplayName to ocidInfoDict's valueForKey:("CFBundleDisplayName")

set ocidBundleVersion to ocidInfoDict's valueForKey:("CFBundleVersion")
set ocidBuild to ocidInfoDict's valueForKey:("DTSDKBuild")
set ocidShortVersionString to ocidInfoDict's valueForKey:("CFBundleShortVersionString")
###クローム用
set ocidChannelID to ocidInfoDict's valueForKey:("KSChannelID")
###Acrobat用
set ocidTrackName to ocidInfoDict's valueForKey:("TrackName")

#####################################
###### diskutil PLIST
#####################################
set ocidDiskutilFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:"diskutil.plist"
###古いファイルはゴミ箱に
set boolResults to (appFileManager's trashItemAtURL:(ocidDiskutilFilePathURL) resultingItemURL:(missing value) |error|:(reference))
#####################################
set strCommandText to "/usr/sbin/diskutil info -plist /" as text
set strPlistData to (do shell script strCommandText) as text
###戻り値をストリングに
set ocidPlistStrings to refMe's NSString's stringWithString:(strPlistData)
###NSDATAにして
set ocidPlisStringstData to ocidPlistStrings's dataUsingEncoding:(refMe's NSUTF8StringEncoding)
###ファイルに書き込み(使い回し用)-->不要な場合は削除して
ocidPlisStringstData's writeToURL:(ocidDiskutilFilePathURL) atomically:true
###PLIST初期化して
set listResults to refMe's NSPropertyListSerialization's propertyListWithData:ocidPlisStringstData options:0 format:(refMe's NSPropertyListXMLFormat_v1_0) |error|:(reference)
###各種値を取得する NSSingleObjectArray に留意
set ocidPlistDataArray to item 1 of listResults
###ボリューム名 他
set ocidVolumeName to (ocidPlistDataArray's valueForKey:"VolumeName")
set ocidDiskUUID to (ocidPlistDataArray's valueForKey:"DiskUUID")
set ocidVolumeUUID to (ocidPlistDataArray's valueForKey:"VolumeUUID")
set ocidFilesystemName to (ocidPlistDataArray's valueForKey:"FilesystemName")
set ocidFileVault to (ocidPlistDataArray's valueForKey:"FileVault")
set ocidEncryption to (ocidPlistDataArray's valueForKey:"Encryption")
###サイズ
set ocidTotalSize to (ocidPlistDataArray's valueForKey:"TotalSize")
set intGB to "1073741824" as integer
set ocidGB to (refMe's NSNumber's numberWithInteger:intGB)
set intTotalSize to ((ocidTotalSize's doubleValue as real) / (ocidGB's doubleValue as real)) as integer
###残
set ocidAPFSContainerFree to (ocidPlistDataArray's valueForKey:"APFSContainerFree")
set intGB to "1073741824" as integer
set ocidGB to (refMe's NSNumber's numberWithInteger:intGB)
set intContainerFree to ((ocidAPFSContainerFree's doubleValue as real) / (ocidGB's doubleValue as real)) as integer
########################
##メモリサイズを調べる
set ocidProcessInfo to refMe's NSProcessInfo's processInfo()
set realMemoryByte to ocidProcessInfo's physicalMemory() as real
set realGB to "1073741824" as real
set intPhysicalMemory to realMemoryByte / realGB as integer
##ユーザー情報
set ocidEnvDict to ocidProcessInfo's environment()
set strHOME to (ocidEnvDict's valueForKey:"HOME") as text
set strUSER to (ocidEnvDict's valueForKey:"USER") as text
set strLOGNAME to (ocidEnvDict's valueForKey:"LOGNAME") as text
set strTMPDIR to (ocidEnvDict's valueForKey:"TMPDIR") as text
########################
###OSのバージョン
set ocidSystemPathArray to (appFileManager's URLsForDirectory:(refMe's NSCoreServiceDirectory) inDomains:(refMe's NSSystemDomainMask))
set ocidCoreServicePathURL to ocidSystemPathArray's firstObject()
set ocidPlistFilePathURL to ocidCoreServicePathURL's URLByAppendingPathComponent:"SystemVersion.plist"
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidPlistFilePathURL)
set strOSversion to (ocidPlistDict's valueForKey:("ProductVersion")) as text
########################
###configCodeにする(後ろから4文字)
set intTextlength to (ocidDeviceSerialNumber's |length|) as integer
set ocidRenge to refMe's NSMakeRange((intTextlength - 4), 4)
set strConfigCode to (ocidDeviceSerialNumber's substringWithRange:(ocidRenge)) as text
###モデル名を取得 configCode
set strURL to "https://support-sp.apple.com/sp/product"
set ocidURLStr to refMe's NSString's stringWithString:(strURL)
set ocidURL to refMe's NSURL's URLWithString:(ocidURLStr)
####コンポーネント
set ocidComponents to refMe's NSURLComponents's alloc()'s initWithURL:(ocidURL) resolvingAgainstBaseURL:false
set ocidComponentArray to refMe's NSMutableArray's alloc()'s initWithCapacity:0
##JSON指定
set ocidQueryItem to refMe's NSURLQueryItem's alloc()'s initWithName:("cc") value:(strConfigCode)
ocidComponentArray's addObject:(ocidQueryItem)
#####アーティスト名から artist idを取得する
set ocidQueryItem to (refMe's NSURLQueryItem's alloc()'s initWithName:("lang") value:(strLocale))
(ocidComponentArray's addObject:(ocidQueryItem))
###検索クエリーとして追加
(ocidComponents's setQueryItems:(ocidComponentArray))
####コンポーネントをURLに展開
set ocidNewURL to ocidComponents's |URL|()
log ocidNewURL's absoluteString() as text

###XML読み込み
set ocidOption to (refMe's NSXMLDocumentTidyXML)
set listReadXMLDoc to refMe's NSXMLDocument's alloc()'s initWithContentsOfURL:(ocidNewURL) options:(ocidOption) |error|:(reference)
set ocidReadXMLDoc to (item 1 of listReadXMLDoc)
###ROOTエレメント
set ocidRootElement to ocidReadXMLDoc's rootElement()
###configCodeからモデル名を取得
set ocidConfigCode to ocidRootElement's elementsForName:"configCode"
set strConfigCode to ocidConfigCode's stringValue as text
####CPUタイプ
set strCPU to CPU type of (system info) as text
log strConfigCode as text

########################
###ダイアログ
set strIconPath to "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/FinderIcon.icns" as text
set aliasIconPath to POSIX file strIconPath as alias


set strAns to ("モデル名:" & strConfigCode & "\r") as text
set strAns to (strAns & "OSバージョン:" & strOSversion & "\r") as text
set strAns to (strAns & "物理メモリ:" & intPhysicalMemory & " GB\r") as text
set strAns to (strAns & "CFBundleExecutable:" & ocidBundleExecutable & "\r") as text
set strAns to (strAns & "ShortVersion:" & ocidShortVersionString & "\r") as text



#####ダイアログを前面に
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if

###ダイアログ
set recordResult to (display dialog "ioreg 戻り値です\rコピーしてメールかメッセージを送ってください\r※相手が信用出来ない場合は削除" with title "モデル番号" default answer strAns buttons {"クリップボードにコピー", "キャンセル", "OK"} default button "OK" giving up after 30 with icon aliasIconPath without hidden answer)
###クリップボードコピー
if button returned of recordResult is "クリップボードにコピー" then
  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)
end if

|

[tool]サポートに必要な情報を取得する(基本情報+対象アプリ)

アプリケーション選択式

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

#!/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 "AppKit"
use scripting additions

property refMe : a reference to current application


###初期化
set appNSWorkspace to refMe's NSWorkspace's sharedWorkspace()
set appFileManager to refMe's NSFileManager's defaultManager()
#####ダイアログを前面に
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
###ダイアログ
set listUTI to {"com.apple.application-bundle"}
###アプリケーションディレクトリ
set ocidUserLibraryPathArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationDirectory) inDomains:(refMe's NSUserDomainMask))
###URL
set ocidAppDirPathURL to ocidUserLibraryPathArray's firstObject()
set aliaAppDirPath to (ocidAppDirPathURL's absoluteURL()) as alias
set aliasAppPath to (choose file with prompt "対象のアプリケーションを選んでください" default location (aliaAppDirPath) of type listUTI with invisibles without showing package contents and multiple selections allowed) as alias
###パス
set strAppPath to POSIX path of aliasAppPath
set ocidAppPathStr to refMe's NSString's stringWithString:(strAppPath)
set ocidAppPath to ocidAppPathStr's stringByStandardizingPath()
set ocidAppPathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidAppPath) isDirectory:true)
#####################################
######ファイル保存先
#####################################
set ocidUserLibraryPathArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidFilePathURL to ocidUserLibraryPathArray's objectAtIndex:0
set ocidSaveDirPathURL to ocidFilePathURL's URLByAppendingPathComponent:"Apple/IOPlatformUUID"
############################
#####属性
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
############################
###フォルダを作る
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
#####################################
###### ioreg PLIST
#####################################
set ocidIoregFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:"ioreg.plist"
###古いファイルはゴミ箱に
set boolResults to (appFileManager's trashItemAtURL:(ocidIoregFilePathURL) resultingItemURL:(missing value) |error|:(reference))
#####################################
set strCommandText to "/usr/sbin/ioreg -c IOPlatformExpertDevice -a " as text
set strPlistData to (do shell script strCommandText) as text
###戻り値をストリングに
set ocidPlistStrings to refMe's NSString's stringWithString:(strPlistData)
###NSDATAにして
set ocidPlisStringstData to ocidPlistStrings's dataUsingEncoding:(refMe's NSUTF8StringEncoding)
###ファイルに書き込み(使い回し用)-->不要な場合は削除して
ocidPlisStringstData's writeToURL:(ocidIoregFilePathURL) atomically:true

###PLIST初期化して
set listResults to refMe's NSPropertyListSerialization's propertyListWithData:ocidPlisStringstData options:0 format:(refMe's NSPropertyListXMLFormat_v1_0) |error|:(reference)
###各種値を取得する NSSingleObjectArray に留意
set ocidPlistDataArray to item 1 of listResults
set ocidDeviceUUIDArray to (ocidPlistDataArray's valueForKeyPath:"IORegistryEntryChildren.IOPlatformUUID")
set ocidDeviceUUID to ocidDeviceUUIDArray's firstObject()
set ocidDeviceSerialNumberArray to (ocidPlistDataArray's valueForKeyPath:"IORegistryEntryChildren.IOPlatformSerialNumber")
set ocidDeviceSerialNumber to ocidDeviceSerialNumberArray's firstObject()
set ocidDeviceEntryNameArray to (ocidPlistDataArray's valueForKeyPath:"IORegistryEntryChildren.IORegistryEntryName")
set ocidDeviceEntryName to ocidDeviceEntryNameArray's firstObject()
###モデル名はNSDATAなのでテキストに解凍する
set ocidModelArray to (ocidPlistDataArray's valueForKeyPath:("IORegistryEntryChildren.model"))
set ocidModel to ocidModelArray's firstObject()
###まぁエラーになるとは思えないが
if (className() of ocidModel as text) is "NSNull" then
  set strCommandText to ("/usr/sbin/sysctl -n hw.model") as text
  set strModelStr to (do shell script strCommandText) as text
else
  set ocidModelStr to refMe's NSString's alloc()'s initWithData:(ocidModel) encoding:(refMe's NSUTF8StringEncoding)
  set strModelStr to ocidModelStr as text
end if
#####################################
######サポート情報取得
#####################################
###バンドル
set ocidAppBundle to refMe's NSBundle's bundleWithURL:(ocidAppPathURL)
set strFilePath to ocidAppPathURL's |path|() as text

###基本情報を取得
set ocidInfoDict to ocidAppBundle's infoDictionary
###PLISTのURLを取得して
# set ocidPlistPathURL to ocidAppBundlePathURL's URLByAppendingPathComponent:("Contents/Info.plist") isDirectory:false
###読み込む
#set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidPlistPathURL)
set ocidBundleName to ocidInfoDict's valueForKey:("CFBundleName")
set ocidBundleExecutable to ocidInfoDict's valueForKey:("CFBundleExecutable")
set ocidBundleDisplayName to ocidInfoDict's valueForKey:("CFBundleDisplayName")

set ocidBundleVersion to ocidInfoDict's valueForKey:("CFBundleVersion")
set ocidBuild to ocidInfoDict's valueForKey:("DTSDKBuild")
set ocidShortVersionString to ocidInfoDict's valueForKey:("CFBundleShortVersionString")
###クローム用
set ocidChannelID to ocidInfoDict's valueForKey:("KSChannelID")
###Acrobat用
set ocidTrackName to ocidInfoDict's valueForKey:("TrackName")

#####################################
###### diskutil PLIST
#####################################
set ocidDiskutilFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:"diskutil.plist"
###古いファイルはゴミ箱に
set boolResults to (appFileManager's trashItemAtURL:(ocidDiskutilFilePathURL) resultingItemURL:(missing value) |error|:(reference))
#####################################
set strCommandText to "/usr/sbin/diskutil info -plist /" as text
set strPlistData to (do shell script strCommandText) as text
###戻り値をストリングに
set ocidPlistStrings to refMe's NSString's stringWithString:(strPlistData)
###NSDATAにして
set ocidPlisStringstData to ocidPlistStrings's dataUsingEncoding:(refMe's NSUTF8StringEncoding)
###ファイルに書き込み(使い回し用)-->不要な場合は削除して
ocidPlisStringstData's writeToURL:(ocidDiskutilFilePathURL) atomically:true
###PLIST初期化して
set listResults to refMe's NSPropertyListSerialization's propertyListWithData:ocidPlisStringstData options:0 format:(refMe's NSPropertyListXMLFormat_v1_0) |error|:(reference)
###各種値を取得する NSSingleObjectArray に留意
set ocidPlistDataArray to item 1 of listResults
###ボリューム名 他
set ocidVolumeName to (ocidPlistDataArray's valueForKey:"VolumeName")
set ocidDiskUUID to (ocidPlistDataArray's valueForKey:"DiskUUID")
set ocidVolumeUUID to (ocidPlistDataArray's valueForKey:"VolumeUUID")
set ocidFilesystemName to (ocidPlistDataArray's valueForKey:"FilesystemName")
set ocidFileVault to (ocidPlistDataArray's valueForKey:"FileVault")
set ocidEncryption to (ocidPlistDataArray's valueForKey:"Encryption")
###サイズ
set ocidTotalSize to (ocidPlistDataArray's valueForKey:"TotalSize")
set intGB to "1073741824" as integer
set ocidGB to (refMe's NSNumber's numberWithInteger:intGB)
set intTotalSize to ((ocidTotalSize's doubleValue as real) / (ocidGB's doubleValue as real)) as integer
###残
set ocidAPFSContainerFree to (ocidPlistDataArray's valueForKey:"APFSContainerFree")
set intGB to "1073741824" as integer
set ocidGB to (refMe's NSNumber's numberWithInteger:intGB)
set intContainerFree to ((ocidAPFSContainerFree's doubleValue as real) / (ocidGB's doubleValue as real)) as integer
########################
##メモリサイズを調べる
set ocidProcessInfo to refMe's NSProcessInfo's processInfo()
set realMemoryByte to ocidProcessInfo's physicalMemory() as real
set realGB to "1073741824" as real
set intPhysicalMemory to realMemoryByte / realGB as integer
##ユーザー情報
set ocidEnvDict to ocidProcessInfo's environment()
set strHOME to (ocidEnvDict's valueForKey:"HOME") as text
set strUSER to (ocidEnvDict's valueForKey:"USER") as text
set strLOGNAME to (ocidEnvDict's valueForKey:"LOGNAME") as text
set strTMPDIR to (ocidEnvDict's valueForKey:"TMPDIR") as text
########################
###OSのバージョン
set ocidSystemPathArray to (appFileManager's URLsForDirectory:(refMe's NSCoreServiceDirectory) inDomains:(refMe's NSSystemDomainMask))
set ocidCoreServicePathURL to ocidSystemPathArray's firstObject()
set ocidPlistFilePathURL to ocidCoreServicePathURL's URLByAppendingPathComponent:"SystemVersion.plist"
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidPlistFilePathURL)
set strOSversion to (ocidPlistDict's valueForKey:("ProductVersion")) as text
########################
###configCodeにする(後ろから4文字)
set intTextlength to (ocidDeviceSerialNumber's |length|) as integer
set ocidRenge to refMe's NSMakeRange((intTextlength - 4), 4)
set strConfigCode to (ocidDeviceSerialNumber's substringWithRange:(ocidRenge)) as text
###モデル名を取得 configCode
set strURL to "https://support-sp.apple.com/sp/product"
set ocidURLStr to refMe's NSString's stringWithString:(strURL)
set ocidURL to refMe's NSURL's URLWithString:(ocidURLStr)
###コンフィグコードでクエリーを設定
##コンポーネントをURLで初期化
set ocidComponents to refMe's NSURLComponents's alloc()'s initWithURL:(ocidURL) resolvingAgainstBaseURL:false
##setQueryの場合
# set strQueryItem to ("cc=" & strConfigCode) as text
# ocidComponents's setQuery:(strQueryItem)
###setQueryItemsの場合
set ocidQueryItem to refMe's NSURLQueryItem's alloc()'s initWithName:("cc") value:(strConfigCode)
ocidComponents's setQueryItems:({ocidQueryItem})
###URLにして
set ocidNewURL to ocidComponents's |URL|()
###XML読み込み
set ocidOption to (refMe's NSXMLDocumentTidyXML)
set listReadXMLDoc to refMe's NSXMLDocument's alloc()'s initWithContentsOfURL:(ocidNewURL) options:(ocidOption) |error|:(reference)
set ocidReadXMLDoc to (item 1 of listReadXMLDoc)
###ROOTエレメント
set ocidRootElement to ocidReadXMLDoc's rootElement()
###configCodeからモデル名を取得
set ocidConfigCode to ocidRootElement's elementsForName:"configCode"
set strConfigCode to ocidConfigCode's stringValue as text
####CPUタイプ
set strCPU to CPU type of (system info) as text

########################
###ダイアログ
set strIconPath to "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/FinderIcon.icns" as text
set aliasIconPath to POSIX file strIconPath as alias

set strAns to ("デバイス型番:" & ocidDeviceEntryName & "\r") as text
set strAns to (strAns & "モデル番号:" & strModelStr & "\r") as text
set strAns to (strAns & "モデル名:" & strConfigCode & "\r") as text
set strAns to (strAns & "※デバイスUUID:" & ocidDeviceUUID & "\r") as text
set strAns to (strAns & "※シリアル番号:" & ocidDeviceSerialNumber & "\r") as text
set strAns to (strAns & "OSバージョン:" & strOSversion & "\r") as text
set strAns to (strAns & "CPU:" & strCPU & "\r") as text
set strAns to (strAns & "----+----1----+----2----+-----3----+----4----+----5\r") as text
set strAns to (strAns & "起動ボリューム名:" & ocidVolumeName & "\r") as text
set strAns to (strAns & "※ディスクUUID:" & ocidDiskUUID & "\r") as text
set strAns to (strAns & "※ボリュームUUID:" & ocidVolumeUUID & "\r") as text
set strAns to (strAns & "ファイルシステム:" & ocidFilesystemName & "\r") as text
set strAns to (strAns & "FileVault:" & ocidFileVault & "\r") as text
set strAns to (strAns & "暗号化:" & ocidEncryption & "\r") as text
set strAns to (strAns & "ディスクサイズ:" & intTotalSize & " GB\r") as text
set strAns to (strAns & "ディスク残:" & intContainerFree & " GB\r") as text
set strAns to (strAns & "物理メモリ:" & intPhysicalMemory & " GB\r") as text
set strAns to (strAns & "----+----1----+----2----+-----3----+----4----+----5\r") as text
set strAns to (strAns & "ホーム:" & strHOME & "\r") as text
set strAns to (strAns & "ユーザー名:" & strUSER & "\r") as text
set strAns to (strAns & "ログイン名:" & strLOGNAME & "\r") as text
set strAns to (strAns & "※テンポラリ:" & strTMPDIR & "\r") as text
set strAns to (strAns & "----+----1----+----2----+-----3----+----4----+----5\r") as text
set strAns to (strAns & "CFBundleName:" & ocidBundleName & "\r") as text
set strAns to (strAns & "CFBundleExecutable:" & ocidBundleExecutable & "\r") as text
set strAns to (strAns & "CFBundleDisplayName:" & ocidBundleDisplayName & "\r") as text
set strAns to (strAns & "CFBundleVersion:" & ocidBundleVersion & "\r") as text
set strAns to (strAns & "DTSDKBuild:" & ocidBuild & "\r") as text
set strAns to (strAns & "ShortVersion:" & ocidShortVersionString & "\r") as text
set strAns to (strAns & "KSChannelID:" & ocidChannelID & "\r") as text
set strAns to (strAns & "TrackName:" & ocidTrackName & "\r") as text
set strAns to (strAns & "インストールパス:" & strFilePath & "\r") as text


#####ダイアログを前面に
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if

###ダイアログ
set recordResult to (display dialog "ioreg 戻り値です\rコピーしてメールかメッセージを送ってください\r※相手が信用出来ない場合は削除" with title "モデル番号" default answer strAns buttons {"クリップボードにコピー", "キャンセル", "OK"} default button "OK" giving up after 30 with icon aliasIconPath without hidden answer)
###クリップボードコピー
if button returned of recordResult is "クリップボードにコピー" then
  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)
end if

UTI指定式

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

#!/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 "AppKit"
use scripting additions

property refMe : a reference to current application

###サポートするアプリのUTI
set strUTI to "com.google.Chrome"


###初期化
set appNSWorkspace to refMe's NSWorkspace's sharedWorkspace()
set appFileManager to refMe's NSFileManager's defaultManager()
#####################################
######ファイル保存先
#####################################
set ocidUserLibraryPathArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidFilePathURL to ocidUserLibraryPathArray's objectAtIndex:0
set ocidSaveDirPathURL to ocidFilePathURL's URLByAppendingPathComponent:"Apple/IOPlatformUUID"
############################
#####属性
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
############################
###フォルダを作る
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
#####################################
###### ioreg PLIST
#####################################
set ocidIoregFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:"ioreg.plist"
###古いファイルはゴミ箱に
set boolResults to (appFileManager's trashItemAtURL:(ocidIoregFilePathURL) resultingItemURL:(missing value) |error|:(reference))
#####################################
set strCommandText to "/usr/sbin/ioreg -c IOPlatformExpertDevice -a " as text
set strPlistData to (do shell script strCommandText) as text
###戻り値をストリングに
set ocidPlistStrings to refMe's NSString's stringWithString:(strPlistData)
###NSDATAにして
set ocidPlisStringstData to ocidPlistStrings's dataUsingEncoding:(refMe's NSUTF8StringEncoding)
###ファイルに書き込み(使い回し用)-->不要な場合は削除して
ocidPlisStringstData's writeToURL:(ocidIoregFilePathURL) atomically:true

###PLIST初期化して
set listResults to refMe's NSPropertyListSerialization's propertyListWithData:ocidPlisStringstData options:0 format:(refMe's NSPropertyListXMLFormat_v1_0) |error|:(reference)
###各種値を取得する NSSingleObjectArray に留意
set ocidPlistDataArray to item 1 of listResults
set ocidDeviceUUIDArray to (ocidPlistDataArray's valueForKeyPath:"IORegistryEntryChildren.IOPlatformUUID")
set ocidDeviceUUID to ocidDeviceUUIDArray's firstObject()
set ocidDeviceSerialNumberArray to (ocidPlistDataArray's valueForKeyPath:"IORegistryEntryChildren.IOPlatformSerialNumber")
set ocidDeviceSerialNumber to ocidDeviceSerialNumberArray's firstObject()
set ocidDeviceEntryNameArray to (ocidPlistDataArray's valueForKeyPath:"IORegistryEntryChildren.IORegistryEntryName")
set ocidDeviceEntryName to ocidDeviceEntryNameArray's firstObject()
###モデル名はNSDATAなのでテキストに解凍する
set ocidModelArray to (ocidPlistDataArray's valueForKeyPath:("IORegistryEntryChildren.model"))
set ocidModel to ocidModelArray's firstObject()
###まぁエラーになるとは思えないが
if (className() of ocidModel as text) is "NSNull" then
  set strCommandText to ("/usr/sbin/sysctl -n hw.model") as text
  set strModelStr to (do shell script strCommandText) as text
else
  set ocidModelStr to refMe's NSString's alloc()'s initWithData:(ocidModel) encoding:(refMe's NSUTF8StringEncoding)
  set strModelStr to ocidModelStr as text
end if
#####################################
######サポート情報取得
#####################################
###バンドル
set ocidAppBundle to refMe's NSBundle's bundleWithIdentifier:(strUTI)
###インストール先の取得
if ocidAppBundle is not (missing value) then
  set ocidAppBundlePathURL to ocidAppBundle's bundleURL()
  set strFilePath to ocidAppBundlePathURL's |path|() as text
else
  set ocidAppBundlePathURL to appNSWorkspace's URLForApplicationWithBundleIdentifier:(strUTI)
  set ocidAppBundle to refMe's NSBundle's bundleWithURL:(ocidAppBundlePathURL)
  set strFilePath to ocidAppBundlePathURL's |path|() as text
end if
###基本情報を取得
set ocidInfoDict to ocidAppBundle's infoDictionary
###PLISTのURLを取得して
# set ocidPlistPathURL to ocidAppBundlePathURL's URLByAppendingPathComponent:("Contents/Info.plist") isDirectory:false
###読み込む
#set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidPlistPathURL)
set ocidBundleName to ocidInfoDict's valueForKey:("CFBundleName")
set ocidBundleVersion to ocidInfoDict's valueForKey:("CFBundleVersion")
set ocidBuild to ocidInfoDict's valueForKey:("DTSDKBuild")
set ocidShortVersionString to ocidInfoDict's valueForKey:("CFBundleShortVersionString")
###クローム用
set ocidChannelID to ocidInfoDict's valueForKey:("KSChannelID")
###Acrobat用
set ocidTrackName to ocidInfoDict's valueForKey:("TrackName")

#####################################
###### diskutil PLIST
#####################################
set ocidDiskutilFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:"diskutil.plist"
###古いファイルはゴミ箱に
set boolResults to (appFileManager's trashItemAtURL:(ocidDiskutilFilePathURL) resultingItemURL:(missing value) |error|:(reference))
#####################################
set strCommandText to "/usr/sbin/diskutil info -plist /" as text
set strPlistData to (do shell script strCommandText) as text
###戻り値をストリングに
set ocidPlistStrings to refMe's NSString's stringWithString:(strPlistData)
###NSDATAにして
set ocidPlisStringstData to ocidPlistStrings's dataUsingEncoding:(refMe's NSUTF8StringEncoding)
###ファイルに書き込み(使い回し用)-->不要な場合は削除して
ocidPlisStringstData's writeToURL:(ocidDiskutilFilePathURL) atomically:true
###PLIST初期化して
set listResults to refMe's NSPropertyListSerialization's propertyListWithData:ocidPlisStringstData options:0 format:(refMe's NSPropertyListXMLFormat_v1_0) |error|:(reference)
###各種値を取得する NSSingleObjectArray に留意
set ocidPlistDataArray to item 1 of listResults
###ボリューム名 他
set ocidVolumeName to (ocidPlistDataArray's valueForKey:"VolumeName")
set ocidDiskUUID to (ocidPlistDataArray's valueForKey:"DiskUUID")
set ocidVolumeUUID to (ocidPlistDataArray's valueForKey:"VolumeUUID")
set ocidFilesystemName to (ocidPlistDataArray's valueForKey:"FilesystemName")
set ocidFileVault to (ocidPlistDataArray's valueForKey:"FileVault")
set ocidEncryption to (ocidPlistDataArray's valueForKey:"Encryption")
###サイズ
set ocidTotalSize to (ocidPlistDataArray's valueForKey:"TotalSize")
set intGB to "1073741824" as integer
set ocidGB to (refMe's NSNumber's numberWithInteger:intGB)
set intTotalSize to ((ocidTotalSize's doubleValue as real) / (ocidGB's doubleValue as real)) as integer
###残
set ocidAPFSContainerFree to (ocidPlistDataArray's valueForKey:"APFSContainerFree")
set intGB to "1073741824" as integer
set ocidGB to (refMe's NSNumber's numberWithInteger:intGB)
set intContainerFree to ((ocidAPFSContainerFree's doubleValue as real) / (ocidGB's doubleValue as real)) as integer
########################
##メモリサイズを調べる
set ocidProcessInfo to refMe's NSProcessInfo's processInfo()
set realMemoryByte to ocidProcessInfo's physicalMemory() as real
set realGB to "1073741824" as real
set intPhysicalMemory to realMemoryByte / realGB as integer
##ユーザー情報
set ocidEnvDict to ocidProcessInfo's environment()
set strHOME to (ocidEnvDict's valueForKey:"HOME") as text
set strUSER to (ocidEnvDict's valueForKey:"USER") as text
set strLOGNAME to (ocidEnvDict's valueForKey:"LOGNAME") as text
set strTMPDIR to (ocidEnvDict's valueForKey:"TMPDIR") as text
########################
###OSのバージョン
set ocidSystemPathArray to (appFileManager's URLsForDirectory:(refMe's NSCoreServiceDirectory) inDomains:(refMe's NSSystemDomainMask))
set ocidCoreServicePathURL to ocidSystemPathArray's firstObject()
set ocidPlistFilePathURL to ocidCoreServicePathURL's URLByAppendingPathComponent:"SystemVersion.plist"
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidPlistFilePathURL)
set strOSversion to (ocidPlistDict's valueForKey:("ProductVersion")) as text
########################
###configCodeにする(後ろから4文字)
set intTextlength to (ocidDeviceSerialNumber's |length|) as integer
set ocidRenge to refMe's NSMakeRange((intTextlength - 4), 4)
set strConfigCode to (ocidDeviceSerialNumber's substringWithRange:(ocidRenge)) as text
###モデル名を取得 configCode
set strURL to "https://support-sp.apple.com/sp/product"
set ocidURLStr to refMe's NSString's stringWithString:(strURL)
set ocidURL to refMe's NSURL's URLWithString:(ocidURLStr)
###コンフィグコードでクエリーを設定
##コンポーネントをURLで初期化
set ocidComponents to refMe's NSURLComponents's alloc()'s initWithURL:(ocidURL) resolvingAgainstBaseURL:false
##setQueryの場合
# set strQueryItem to ("cc=" & strConfigCode) as text
# ocidComponents's setQuery:(strQueryItem)
###setQueryItemsの場合
set ocidQueryItem to refMe's NSURLQueryItem's alloc()'s initWithName:("cc") value:(strConfigCode)
ocidComponents's setQueryItems:({ocidQueryItem})
###URLにして
set ocidNewURL to ocidComponents's |URL|()
###XML読み込み
set ocidOption to (refMe's NSXMLDocumentTidyXML)
set listReadXMLDoc to refMe's NSXMLDocument's alloc()'s initWithContentsOfURL:(ocidNewURL) options:(ocidOption) |error|:(reference)
set ocidReadXMLDoc to (item 1 of listReadXMLDoc)
###ROOTエレメント
set ocidRootElement to ocidReadXMLDoc's rootElement()
###configCodeからモデル名を取得
set ocidConfigCode to ocidRootElement's elementsForName:"configCode"
set strConfigCode to ocidConfigCode's stringValue as text
####CPUタイプ
set strCPU to CPU type of (system info) as text

########################
###ダイアログ
set strIconPath to "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/FinderIcon.icns" as text
set aliasIconPath to POSIX file strIconPath as alias

set strAns to ("デバイス型番:" & ocidDeviceEntryName & "\r") as text
set strAns to (strAns & "モデル番号:" & strModelStr & "\r") as text
set strAns to (strAns & "モデル名:" & strConfigCode & "\r") as text
set strAns to (strAns & "※デバイスUUID:" & ocidDeviceUUID & "\r") as text
set strAns to (strAns & "※シリアル番号:" & ocidDeviceSerialNumber & "\r") as text
set strAns to (strAns & "OSバージョン:" & strOSversion & "\r") as text
set strAns to (strAns & "CPU:" & strCPU & "\r") as text
set strAns to (strAns & "----+----1----+----2----+-----3----+----4----+----5\r") as text
set strAns to (strAns & "起動ボリューム名:" & ocidVolumeName & "\r") as text
set strAns to (strAns & "※ディスクUUID:" & ocidDiskUUID & "\r") as text
set strAns to (strAns & "※ボリュームUUID:" & ocidVolumeUUID & "\r") as text
set strAns to (strAns & "ファイルシステム:" & ocidFilesystemName & "\r") as text
set strAns to (strAns & "FileVault:" & ocidFileVault & "\r") as text
set strAns to (strAns & "暗号化:" & ocidEncryption & "\r") as text
set strAns to (strAns & "ディスクサイズ:" & intTotalSize & " GB\r") as text
set strAns to (strAns & "ディスク残:" & intContainerFree & " GB\r") as text
set strAns to (strAns & "物理メモリ:" & intPhysicalMemory & " GB\r") as text
set strAns to (strAns & "----+----1----+----2----+-----3----+----4----+----5\r") as text
set strAns to (strAns & "ホーム:" & strHOME & "\r") as text
set strAns to (strAns & "ユーザー名:" & strUSER & "\r") as text
set strAns to (strAns & "ログイン名:" & strLOGNAME & "\r") as text
set strAns to (strAns & "※テンポラリ:" & strTMPDIR & "\r") as text
set strAns to (strAns & "----+----1----+----2----+-----3----+----4----+----5\r") as text
set strAns to (strAns & "CFBundleName:" & ocidBundleName & "\r") as text
set strAns to (strAns & "CFBundleVersion:" & ocidBundleVersion & "\r") as text
set strAns to (strAns & "DTSDKBuild:" & ocidBuild & "\r") as text
set strAns to (strAns & "ShortVersion:" & ocidShortVersionString & "\r") as text
set strAns to (strAns & "KSChannelID:" & ocidChannelID & "\r") as text
set strAns to (strAns & "TrackName:" & ocidTrackName & "\r") as text
set strAns to (strAns & "インストールパス:" & strFilePath & "\r") as text


#####ダイアログを前面に
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if

###ダイアログ
set recordResult to (display dialog "ioreg 戻り値です\rコピーしてメールかメッセージを送ってください\r※相手が信用出来ない場合は削除" with title "モデル番号" default answer strAns buttons {"クリップボードにコピー", "キャンセル", "OK"} default button "OK" giving up after 30 with icon aliasIconPath without hidden answer)
###クリップボードコピー
if button returned of recordResult is "クリップボードにコピー" then
  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)
end if

|

[tool]サポートに必要な情報を取得する(基本情報のみ)


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

#!/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 ocidUserLibraryPathArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidFilePathURL to ocidUserLibraryPathArray's objectAtIndex:0
set ocidSaveDirPathURL to ocidFilePathURL's URLByAppendingPathComponent:"Apple/IOPlatformUUID"
############################
#####属性
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
############################
###フォルダを作る
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
#####################################
###### ioreg PLIST
#####################################
set ocidIoregFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:"ioreg.plist"
###古いファイルはゴミ箱に
set boolResults to (appFileManager's trashItemAtURL:(ocidIoregFilePathURL) resultingItemURL:(missing value) |error|:(reference))
#####################################
set strCommandText to "/usr/sbin/ioreg -c IOPlatformExpertDevice -a " as text
set strPlistData to (do shell script strCommandText) as text
###戻り値をストリングに
set ocidPlistStrings to refMe's NSString's stringWithString:(strPlistData)
###NSDATAにして
set ocidPlisStringstData to ocidPlistStrings's dataUsingEncoding:(refMe's NSUTF8StringEncoding)
###ファイルに書き込み(使い回し用)-->不要な場合は削除して
ocidPlisStringstData's writeToURL:(ocidIoregFilePathURL) atomically:true

###PLIST初期化して
set listResults to refMe's NSPropertyListSerialization's propertyListWithData:ocidPlisStringstData options:0 format:(refMe's NSPropertyListXMLFormat_v1_0) |error|:(reference)
###各種値を取得する NSSingleObjectArray に留意
set ocidPlistDataArray to item 1 of listResults
set ocidDeviceUUIDArray to (ocidPlistDataArray's valueForKeyPath:"IORegistryEntryChildren.IOPlatformUUID")
set ocidDeviceUUID to ocidDeviceUUIDArray's firstObject()
set ocidDeviceSerialNumberArray to (ocidPlistDataArray's valueForKeyPath:"IORegistryEntryChildren.IOPlatformSerialNumber")
set ocidDeviceSerialNumber to ocidDeviceSerialNumberArray's firstObject()
set ocidDeviceEntryNameArray to (ocidPlistDataArray's valueForKeyPath:"IORegistryEntryChildren.IORegistryEntryName")
set ocidDeviceEntryName to ocidDeviceEntryNameArray's firstObject()
###モデル名はNSDATAなのでテキストに解凍する
set ocidModelArray to (ocidPlistDataArray's valueForKeyPath:("IORegistryEntryChildren.model"))
set ocidModel to ocidModelArray's firstObject()
###まぁエラーになるとは思えないが
if (className() of ocidModel as text) is "NSNull" then
  set strCommandText to ("/usr/sbin/sysctl -n hw.model") as text
  set strModelStr to (do shell script strCommandText) as text
else
  set ocidModelStr to refMe's NSString's alloc()'s initWithData:(ocidModel) encoding:(refMe's NSUTF8StringEncoding)
  set strModelStr to ocidModelStr as text
end if


#####################################
###### diskutil PLIST
#####################################
set ocidDiskutilFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:"diskutil.plist"
###古いファイルはゴミ箱に
set boolResults to (appFileManager's trashItemAtURL:(ocidDiskutilFilePathURL) resultingItemURL:(missing value) |error|:(reference))
#####################################
set strCommandText to "/usr/sbin/diskutil info -plist /" as text
set strPlistData to (do shell script strCommandText) as text
###戻り値をストリングに
set ocidPlistStrings to refMe's NSString's stringWithString:(strPlistData)
###NSDATAにして
set ocidPlisStringstData to ocidPlistStrings's dataUsingEncoding:(refMe's NSUTF8StringEncoding)
###ファイルに書き込み(使い回し用)-->不要な場合は削除して
ocidPlisStringstData's writeToURL:(ocidDiskutilFilePathURL) atomically:true
###PLIST初期化して
set listResults to refMe's NSPropertyListSerialization's propertyListWithData:ocidPlisStringstData options:0 format:(refMe's NSPropertyListXMLFormat_v1_0) |error|:(reference)
###各種値を取得する NSSingleObjectArray に留意
set ocidPlistDataArray to item 1 of listResults
###ボリューム名 他
set ocidVolumeName to (ocidPlistDataArray's valueForKey:"VolumeName")
set ocidDiskUUID to (ocidPlistDataArray's valueForKey:"DiskUUID")
set ocidVolumeUUID to (ocidPlistDataArray's valueForKey:"VolumeUUID")
set ocidFilesystemName to (ocidPlistDataArray's valueForKey:"FilesystemName")
set ocidFileVault to (ocidPlistDataArray's valueForKey:"FileVault")
set ocidEncryption to (ocidPlistDataArray's valueForKey:"Encryption")
###サイズ
set ocidTotalSize to (ocidPlistDataArray's valueForKey:"TotalSize")
set intGB to "1073741824" as integer
set ocidGB to (refMe's NSNumber's numberWithInteger:intGB)
set intTotalSize to ((ocidTotalSize's doubleValue as real) / (ocidGB's doubleValue as real)) as integer
###残
set ocidAPFSContainerFree to (ocidPlistDataArray's valueForKey:"APFSContainerFree")
set intGB to "1073741824" as integer
set ocidGB to (refMe's NSNumber's numberWithInteger:intGB)
set intContainerFree to ((ocidAPFSContainerFree's doubleValue as real) / (ocidGB's doubleValue as real)) as integer
########################
##メモリサイズを調べる
set ocidProcessInfo to refMe's NSProcessInfo's processInfo()
set realMemoryByte to ocidProcessInfo's physicalMemory() as real
set realGB to "1073741824" as real
set intPhysicalMemory to realMemoryByte / realGB as integer
##ユーザー情報
set ocidEnvDict to ocidProcessInfo's environment()
set strHOME to (ocidEnvDict's valueForKey:"HOME") as text
set strUSER to (ocidEnvDict's valueForKey:"USER") as text
set strLOGNAME to (ocidEnvDict's valueForKey:"LOGNAME") as text
set strTMPDIR to (ocidEnvDict's valueForKey:"TMPDIR") as text
########################
###OSのバージョン
set ocidSystemPathArray to (appFileManager's URLsForDirectory:(refMe's NSCoreServiceDirectory) inDomains:(refMe's NSSystemDomainMask))
set ocidCoreServicePathURL to ocidSystemPathArray's firstObject()
set ocidPlistFilePathURL to ocidCoreServicePathURL's URLByAppendingPathComponent:"SystemVersion.plist"
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidPlistFilePathURL)
set strOSversion to (ocidPlistDict's valueForKey:("ProductVersion")) as text
########################
###configCodeにする(後ろから4文字)
set intTextlength to (ocidDeviceSerialNumber's |length|) as integer
set ocidRenge to refMe's NSMakeRange((intTextlength - 4), 4)
set strConfigCode to (ocidDeviceSerialNumber's substringWithRange:(ocidRenge)) as text
###モデル名を取得 configCode
set strURL to "https://support-sp.apple.com/sp/product"
set ocidURLStr to refMe's NSString's stringWithString:(strURL)
set ocidURL to refMe's NSURL's URLWithString:(ocidURLStr)
###コンフィグコードでクエリーを設定
##コンポーネントをURLで初期化
set ocidComponents to refMe's NSURLComponents's alloc()'s initWithURL:(ocidURL) resolvingAgainstBaseURL:false
##setQueryの場合
# set strQueryItem to ("cc=" & strConfigCode) as text
# ocidComponents's setQuery:(strQueryItem)
###setQueryItemsの場合
set ocidQueryItem to refMe's NSURLQueryItem's alloc()'s initWithName:("cc") value:(strConfigCode)
ocidComponents's setQueryItems:({ocidQueryItem})
###URLにして
set ocidNewURL to ocidComponents's |URL|()
###XML読み込み
set ocidOption to (refMe's NSXMLDocumentTidyXML)
set listReadXMLDoc to refMe's NSXMLDocument's alloc()'s initWithContentsOfURL:(ocidNewURL) options:(ocidOption) |error|:(reference)
set ocidReadXMLDoc to (item 1 of listReadXMLDoc)
###ROOTエレメント
set ocidRootElement to ocidReadXMLDoc's rootElement()
###configCodeからモデル名を取得
set ocidConfigCode to ocidRootElement's elementsForName:"configCode"
set strConfigCode to ocidConfigCode's stringValue as text
####CPUタイプ
set strCPU to CPU type of (system info) as text

########################
###ダイアログ
set strIconPath to "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/FinderIcon.icns" as text
set aliasIconPath to POSIX file strIconPath as alias

set strAns to ("デバイス型番:" & ocidDeviceEntryName & "\r") as text
set strAns to (strAns & "モデル番号:" & strModelStr & "\r") as text
set strAns to (strAns & "モデル名:" & strConfigCode & "\r") as text
set strAns to (strAns & "デバイスUUID:" & ocidDeviceUUID & "\r") as text
set strAns to (strAns & "シリアル番号:" & ocidDeviceSerialNumber & "\r") as text
set strAns to (strAns & "OSバージョン:" & strOSversion & "\r") as text
set strAns to (strAns & "CPU:" & strCPU & "\r") as text
set strAns to (strAns & "----+----1----+----2----+-----3----+----4----+----5\r") as text
set strAns to (strAns & "起動ボリューム名:" & ocidVolumeName & "\r") as text
set strAns to (strAns & "ディスクUUID:" & ocidDiskUUID & "\r") as text
set strAns to (strAns & "ボリュームUUID:" & ocidVolumeUUID & "\r") as text
set strAns to (strAns & "ファイルシステム:" & ocidFilesystemName & "\r") as text
set strAns to (strAns & "FileVault:" & ocidFileVault & "\r") as text
set strAns to (strAns & "暗号化:" & ocidEncryption & "\r") as text
set strAns to (strAns & "ディスクサイズ:" & intTotalSize & " GB\r") as text
set strAns to (strAns & "ディスク残:" & intContainerFree & " GB\r") as text
set strAns to (strAns & "物理メモリ:" & intPhysicalMemory & " GB\r") as text
set strAns to (strAns & "----+----1----+----2----+-----3----+----4----+----5\r") as text
set strAns to (strAns & "ホーム:" & strHOME & "\r") as text
set strAns to (strAns & "ユーザー名:" & strUSER & "\r") as text
set strAns to (strAns & "ログイン名:" & strLOGNAME & "\r") as text
set strAns to (strAns & "テンポラリ:" & strTMPDIR & " \r") as text


#####ダイアログを前面に
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if

###ダイアログ
set recordResult to (display dialog "ioreg 戻り値です\rコピーしてメールかメッセージを送ってください" with title "モデル番号" default answer strAns buttons {"クリップボードにコピー", "キャンセル", "OK"} default button "OK" giving up after 20 with icon aliasIconPath without hidden answer)
###クリップボードコピー
if button returned of recordResult is "クリップボードにコピー" then
  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)
end if

|

[configCode] support-sp.apple.comのクエリ値configCodeの取得

configCodeはシリアル番号の下4桁です
そこからsupport-sp.apple.comを利用して
マックのモデル名が取得できます

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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
# BaseURL https://checkcoverage.apple.com
#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()
#################################################
######ファイル保存先 書類>>Apple >> IOPlatformUUID
#################################################
set ocidUserLibraryPathArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidFilePathURL to ocidUserLibraryPathArray's objectAtIndex:0
set ocidSaveDirPathURL to ocidFilePathURL's URLByAppendingPathComponent:"Apple/IOPlatformUUID"
############################
#####属性
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
############################
###フォルダを作る
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
#####################################
######PLISTパス
#####################################
set ocidFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:"ioreg.plist"
set strFilePath to (ocidFilePathURL's |path|()) as text
###古いファイルはゴミ箱に
set boolResults to (appFileManager's trashItemAtURL:ocidFilePathURL resultingItemURL:(missing value) |error|:(reference))

#####################################
set strCommandText to "/usr/sbin/ioreg -c IOPlatformExpertDevice -a " as text
set strPlistData to (do shell script strCommandText) as text
###戻り値をストリングに
set ocidPlistStrings to refMe's NSString's stringWithString:strPlistData
###NSDATAにして
set ocidPlisStringstData to ocidPlistStrings's dataUsingEncoding:(refMe's NSUTF8StringEncoding)
###ファイルに書き込み(使い回し用)-->不要な場合は削除して
ocidPlisStringstData's writeToURL:ocidFilePathURL atomically:true
###PLIST初期化して
set listResults to refMe's NSPropertyListSerialization's propertyListWithData:(ocidPlisStringstData) options:0 format:(refMe's NSPropertyListXMLFormat_v1_0) |error|:(reference)
###シリアル番号を取得する
set ocidPlistDataArray to item 1 of listResults
set ocidDeviceSerialNumberArray to (ocidPlistDataArray's valueForKeyPath:"IORegistryEntryChildren.IOPlatformSerialNumber")
set ocidDeviceSerialNumber to ocidDeviceSerialNumberArray's firstObject()
###configCodeにする(後ろから4文字)
set intTextlength to (ocidDeviceSerialNumber's |length|) as integer
set ocidRenge to refMe's NSMakeRange((intTextlength - 4), 4)
set strConfigCode to (ocidDeviceSerialNumber's substringWithRange:(ocidRenge)) as text

###################################################
######URLを整形する
set strURL to "https://support-sp.apple.com/sp/product"
set ocidURLStr to refMe's NSString's stringWithString:(strURL)
set ocidURL to refMe's NSURL's URLWithString:(ocidURLStr)
###コンフィグコードでクエリーを設定
set strQueryItem to ("cc=" & strConfigCode) as text
set ocidComponents to refMe's NSURLComponents's alloc()'s initWithURL:(ocidURL) resolvingAgainstBaseURL:false
ocidComponents's setQuery:(strQueryItem)
###URLにして
set ocidNewURL to ocidComponents's |URL|()
log ocidNewURL's absoluteString() as text
###XML読み込み
set ocidOption to (refMe's NSXMLDocumentTidyXML)
set listReadXMLDoc to refMe's NSXMLDocument's alloc()'s initWithContentsOfURL:(ocidNewURL) options:(ocidOption) |error|:(reference)
set ocidReadXMLDoc to (item 1 of listReadXMLDoc)
###ROOTエレメント
set ocidRootElement to ocidReadXMLDoc's rootElement()
###子要素の数
set numCntChild to ocidRootElement's childCount() as integer
###第一階層だけの子要素
repeat with numCntChild from 0 to (numCntChild - 1)
  log (ocidRootElement's childAtIndex:numCntChild)'s |name| as text
  log (ocidRootElement's childAtIndex:numCntChild)'s stringValue as text
end repeat
set ocidConfigCode to ocidRootElement's elementsForName:"configCode"
log ocidConfigCode's stringValue as text
return (ocidConfigCode's stringValue as text)

|

その他のカテゴリー

Acrobat Acrobat Annotation Acrobat Dialog Acrobat Form Acrobat JS Acrobat Open Acrobat Plugin Acrobat python Acrobat Reader Acrobat Sequ Acrobat Stamps Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin System Information Admin Tools Admin Users Admin Volumes Adobe Apple AppleScript AppleScript Guide AppleScript Accessibility AppleScript AppKit AppleScript Applications AppleScript AppStore AppleScript Archive AppleScript Attributes AppleScript Automator AppleScript AVAsset AppleScript AVconvert AppleScript AVFoundation AppleScript AVURLAsset AppleScript BackUp AppleScript Barcode AppleScript Bash AppleScript Basic AppleScript Basic Path AppleScript Bluetooth AppleScript BOX AppleScript Browser AppleScript Calendar AppleScript CD/DVD AppleScript Choose AppleScript Chrome AppleScript CIImage AppleScript CloudStorage AppleScript Color AppleScript com.apple.LaunchServices.OpenWith AppleScript Console AppleScript Contacts AppleScript CotEditor AppleScript CURL AppleScript current application AppleScript Date&Time AppleScript delimiters AppleScript Desktop AppleScript Device AppleScript Disk AppleScript do shell script AppleScript Dock AppleScript DropBox AppleScript eMail AppleScript Encode Decode AppleScript Error AppleScript EXIFData AppleScript ffmpeg AppleScript File AppleScript Finder AppleScript Firefox AppleScript Folder AppleScript Fonts AppleScript GIF AppleScript HTML AppleScript Icon AppleScript Illustrator AppleScript Image Events AppleScript Image2PDF AppleScript ImageOptim Applescript iWork AppleScript Javascript AppleScript Jedit AppleScript Json AppleScript Label AppleScript List AppleScript locationd AppleScript LRC AppleScript LSSharedFileList AppleScript m3u8 AppleScript MakePDF AppleScript Map AppleScript Math AppleScript Microsoft AppleScript Microsoft Edge AppleScript Microsoft Excel AppleScript Mobileconfig AppleScript Mouse AppleScript Movie AppleScript Music AppleScript NetWork AppleScript Notes AppleScript NSArray AppleScript NSBitmapImageRep AppleScript NSBundle AppleScript NSCFBoolean AppleScript NSCharacterSet AppleScript NSColor AppleScript NSColorList AppleScript NSData AppleScript NSDictionary AppleScript NSError AppleScript NSEvent AppleScript NSFileAttributes AppleScript NSFileManager AppleScript NSFont AppleScript NSFontManager AppleScript NSImage AppleScript NSIndex AppleScript NSKeyedArchiver AppleScript NSKeyedUnarchiver AppleScript NSLocale AppleScript NSMutableArray AppleScript NSMutableDictionary AppleScript NSMutableString AppleScript NSNotFound AppleScript NSNumber AppleScript NSOpenPanel AppleScript NSPasteboard AppleScript NSPDFImageRep AppleScript NSpoint AppleScript NSPredicate AppleScript NSRange AppleScript NSRegularExpression AppleScript NSRunningApplication AppleScript NSScreen AppleScript NSSize AppleScript NSString AppleScript NSStringCompareOptions AppleScript NSTask AppleScript NSTimeZone AppleScript NSURL AppleScript NSURL File AppleScript NSURLBookmark AppleScript NSURLComponents AppleScript NSURLResourceKey AppleScript NSUserDefaults AppleScript NSUUID AppleScript NSView AppleScript NSWorkspace AppleScript Numbers AppleScript OAuth AppleScript ObjC AppleScript OneDrive AppleScript Osax AppleScript PDF AppleScript PDFAnnotationWidget AppleScript PDFContext AppleScript PDFDisplayBox AppleScript PDFDocumentPermissions AppleScript PDFKit AppleScript PDFnUP AppleScript PDFOutline AppleScript Photos AppleScript Photoshop AppleScript Plist System Events AppleScript PostScript AppleScript prefPane AppleScript Preview AppleScript Python AppleScript QR AppleScript QR Decode AppleScript QuickLook AppleScript QuickTime AppleScript record AppleScript Regular Expression AppleScript Reminders AppleScript ReName AppleScript Repeat AppleScript RTF AppleScript Safari AppleScript SaveFile AppleScript ScreenCapture AppleScript ScreenSaver AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript Sort AppleScript Sound AppleScript Spotlight AppleScript SRT AppleScript StandardAdditions AppleScript stringByApplyingTransform AppleScript System Events AppleScript System Settings AppleScript TemporaryItems AppleScript Terminal AppleScript Text AppleScript Text CSV AppleScript Text TSV AppleScript TextEdit AppleScript Translate AppleScript Trash AppleScript Twitter AppleScript UI AppleScript Unit Conversion AppleScript UTType AppleScript valueForKeyPath AppleScript Video AppleScript VisionKit AppleScript Visual Studio Code AppleScript webarchive AppleScript webp AppleScript Wifi AppleScript XML AppleScript XML EPUB AppleScript XML OPML AppleScript XML Plist AppleScript XML RSS AppleScript XML SVG AppleScript XML TTML AppleScript XML webloc AppleScript YouTube AppleScript Zero Suppress Applications Barcode OnLine Tools CityCode Design iPhone List Logs lsappinfo Memo Music perl PlistBuddy pluginkit postalcode ReadMe SF Symbols character id SF Symbols Entity sips Skype Slack sqlite TCC Tools Typography Video Wacom zoom