« PDFのページの回転を確認する | トップページ | Dock基本 »

[com.microsoft.office]バージョンチェッカー


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
(*
com.cocolog-nifty.quicktimer.icefloe
*)
#
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application


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

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

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

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

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

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

################################################
###### 各アプリケーションのUTI取得
################################################
set ocidPackageArray to ocidRootElement's elementsForName:"package"
repeat with itemackageArray in ocidPackageArray
  set ocidElementID to (itemackageArray's childAtIndex:0)'s stringValue()
  log ocidElementID as text
  (*
com.microsoft.office.suite.365
com.microsoft.office.suite.365.businesspro
com.microsoft.word.standalone.365
com.microsoft.excel.standalone.365
com.microsoft.powerpoint.standalone.365
com.microsoft.outlook.standalone.365
com.microsoft.outlook.standalone.365.monthly
com.microsoft.onenote.standalone.365
com.microsoft.onedrive.standalone
com.microsoft.skypeforbusiness.standalone
com.microsoft.teams.standalone
com.microsoft.intunecompanyportal.standalone
com.microsoft.edge
com.microsoft.defender.standalone
com.microsoft.remotedesktop.standalone
com.microsoft.vscode.zip
com.microsoft.autoupdate.standalone
*)
end repeat


################################################
###### 最新のバージョン
################################################
set ocidPackageArray to ocidRootElement's elementsForName:"package"
repeat with itemackageArray in ocidPackageArray
  set ocidElementID to (itemackageArray's childAtIndex:0)'s stringValue()
  if (ocidElementID as text) is "com.microsoft.teams.standalone" then
    set ocidCfbundleversionXML to (itemackageArray's childAtIndex:8)'s stringValue()
  end if
end repeat
log "XML:" & ocidCfbundleversionXML as text
################################################
###### インストール済みのパージョン
################################################
set strPlistPath to "/Applications/Microsoft Teams.app/Contents/Info.plist" as text
set ocidFilePathStr to refMe's NSString's stringWithString:(strPlistPath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
#####PLISTの内容を読み込んで
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
set listReadPlistData to refMe's NSMutableDictionary's dictionaryWithContentsOfURL:ocidFilePathURL |error|:(reference)
set ocidPlistDict to item 1 of listReadPlistData
set ocidCfbundleversionPlist to ocidPlistDict's valueForKey:"CFBundleVersion"
log "PLIST:" & ocidCfbundleversionPlist as text
################################################
###### チェック
################################################
if ocidCfbundleversionPlist is ocidCfbundleversionXML then
return "インストールが必要です"
else
return "最新版を利用中です"
end if



|

« PDFのページの回転を確認する | トップページ | Dock基本 »

Microsoft Office」カテゴリの記事