SCRIPT | Install-ParallelsDesktop26-Latest

ByDan Ashley

SCRIPT | Install-ParallelsDesktop26-Latest

Install Parallels Desktop 26

Summary

This script will install the latest version of Parallels Desktop 26.


Script Content

#!/bin/bash

cd "/Library/Application Support/JAMF/tmp"

# Update variables. These shouldn't need to change for each update
	dmgName="ParallelsDesktop.dmg"
	dmgLink="https://link.parallels.com/pdfm/v26/dmg-download/?experience=enter_key"
	appRunningName="Parallels Desktop"
	appServiceRunningName1="prlctl"
	appServiceRunningName2="prl_client_app"
	appName="Parallels Desktop.app"


# Parallels Desktop license key
	# Uncomment 'licenseKey' variable below and add license key to enable activation
	#licenseKey="XXXXXX-XXXXXX-XXXXXX-XXXXXX-XXXXXX"


# Download latest Parallels Desktop DMG
	echo "Downloading latest Parallels Desktop DMG..."
	curl -L -o $dmgName "$dmgLink"


# Mount the Parallels Desktop .DMG
	echo "Mounting $dmgName..."
	hdiutil mount -nobrowse $dmgName

	# Grab the name of the mounted .dmg as it changes with each version
	dmgMountedName=`ls /Volumes | grep "Parallels"`
	echo "The DMG mounted is: $dmgMountedName"


# Check to see if Parallels Desktop is install, then if it is ensure it is not running
	echo "Checking for any existing installation of Parallels Desktop..."

	if [ -d "/Applications/$appName" ]; then
		ParallelsVersion=`defaults read "/Applications/$appName/Contents/version.plist" CFBundleShortVersionString` 
		echo "The currently installed version of Parallels Desktop is v$ParallelsVersion"

		# Kill the app if it is running
		echo "Killing the app if it is running..."
		killall -Kill "$appRunningName"
		killall -Kill "$appServiceRunningName1"
		killall -Kill "$appServiceRunningName2"
		rm -rf "/Applications/$appName"
	else
		echo "No existing versions of Parallels Desktop detected."
	fi


# Install Parallels Desktop from DMG
	echo "Starting Parallels Desktop installation..."

	"/Volumes/$dmgMountedName/$appName/Contents/MacOS/inittool" install -t "/Applications/$appName" -s

	if [ -d "/Applications/$appName" ]; then
		ParallelsVersion=`defaults read "/Applications/$appName/Contents/version.plist" CFBundleShortVersionString`
		echo "Parallels Desktop version $ParallelsVersion is now installed."
	else
		echo "Parallels Desktop has failed to install correctly."
		exit 1
	fi


# Activate Parallels Desktop license
	echo "Determining license activation method..."

	if [ "$licenseKey" != "" ]; then
		sudo prlsrvctl install-license -k $licenseKey
		echo "Parallels Desktop has been activated using license key."
	else
		echo "No license provided. Parallels Desktop will require activating manually upon use."
	fi


# Unmount the DMG
	hdiutil unmount "/Volumes/$dmgMountedName"


# Remove the downloaded DMG
	rm "/Library/Application Support/JAMF/tmp/$dmgName"


# Clear out the used variables
	unset dmgName
	unset dmgLink
	unset appRunningName
	unset appServiceRunningName1
	unset appServiceRunningName2
	unset appName
	unset licenseKey
	unset dmgMountedName
	unset ParallelsVersion

exit 0

Concluding Comments

This script will install the latest version of the Parallels Desktop 26 application.

About the author

Dan Ashley administrator