msupdatehelper icon indicating copy to clipboard operation
msupdatehelper copied to clipboard

Add function to detect Office 2016 or 2019 and change app id

Open Coros opened this issue 5 years ago • 0 comments

I've added the following function to my fork of the script to make it work with both Office 2016 and Office 2019.

function GetInstalledVersion() {
	local INST_VERSION=$(defaults read "$1"/Contents/Info.plist CFBundleShortVersionString)
	local INST_MAJOR_VERSION=$(echo $INST_VERSION | cut -d "." -f 1 )
	local INST_MINOR_VERSION=$(echo $INST_VERSION | cut -d "." -f 2 )
	
	if (( $INST_MAJOR_VERSION >= 16 )) && (( $INST_MINOR_VERSION < 17 )) ; then
		local APPID_VER="15"
	elif (( $INST_MAJOR_VERSION >= 16 )) && (( $INST_MINOR_VERSION >= 17 )) ; then
		local APPID_VER="2019"
	else
		Debug "Unidentified version: $INST_VERSION"
		exit 1
	fi

	echo "$APPID_VER"
}

I've also updated each update call to look like:

if [ "$UPDATE_WORD" == "true" ]; then
	Debug "Going for Word update"
	APPID_WORD="MSWD"
	APPID_WORD_FMTD=$(echo $APPID_WORD)$(GetInstalledVersion "$PATH_WORD")
	Debug "APPID_WORD_FMTD: APPID_WORD_FMTD"
	RegisterApp "$PATH_WORD" "$APPID_WORD_FMTD"
	SetTargetVersion "$VERSION_WORD"
	PerformUpdate "$APPID_WORD_FMTD" "$TARGET_VERSION"
else
	Debug "Update for Word disabled"
fi

Coros avatar Feb 03 '20 20:02 Coros