To supplement last week’s post on automatically mounting an external drive to create a clone, here is a quick tip for doing the same thing with an encrypted APFS volume. Ideally, you should be encrypting your backups. If you’re running macOS 10.13 High Sierra, or the impending macOS Mojave, then you will be cloning your system to an APFS volume. If that’s the case, you’ll need to no how to automatically unlock APFS volume with AppleScript.
- Applescript Run App When Unlocked Macbook Air
- Run Applescript From Terminal
- Apple Applescript
- Applescript To Open Application
- Applescript Run App When Unlocked Mac Pro
- Applescript Run App When Unlocked Macbook Pro
Automatically unlock APFS volume with AppleScript
Applescript Run App When Unlocked Macbook Air
![App App](/uploads/1/3/4/2/134256816/281731924.jpg)
These handlers run when certain events occur. The run event handler is called when a script runs. By default, any executable code at the top level of a script—that is, not contained within a handler or script object—is considered to be contained within an implicit run handler. See Listing 13-17 and Listing 13-18. Run an AppleScript with VB.; 2 minutes to read; In this article. Call an AppleScript file from a VB macro in Office 2016 for Mac. Applies to: Excel for Mac PowerPoint for Mac Word for Mac Office 2016 for Mac. The AppleScriptTask command executes an AppleScript script file located outside the sandboxed app.
There is a little more work involved here, but none of it difficult. The file system might be new, but diskutil is still the command line program doing all the work managing volumes. There is simply a couple more commands involved. This assumes you have already encrypted the drive with Disk Utility.
To mount, or rather unlock an encrypted APFS volume with AppleScript, we need the following information:
- APFS volume ID
- Cryptographic user ID
- The encryption password
The password is the same one you used when you formatted the drive. Here is how to get the other two pieces of the puzzle.
- Find the APFS volume ID for your clone drive. You can see this information clearly in Disk Utility. For every volume listed there is a table of information, the device field has what you are looking for. It is some variation of disk1s1. Or if you prefer, with the drive already mounted you can run a terminal command to have the information of all your drives listed, like so:
![Applescript run app when unlocked mac pro Applescript run app when unlocked mac pro](/uploads/1/3/4/2/134256816/421716909.jpg)
App mac download music.
diskutil apfs list
That command will take a moment, then print a whole lot of information to screen like below. Look for volume you intend to clone your system to and note down the APFS Volume Disk.
Run Applescript From Terminal
- Once you have the volume ID. In the terminal run the following command (replace ‘apfs_volume_id’ with your disk)
diskutil apfs listcryptousers /dev/apfs_volume_id
You will get something that looks like this:
That long alphanumeric code is the Cryptographic user. Copy that code and you have everything you need to make your AppleScript work.
Apple Applescript
- Create the AppleScript to automatically mount your encrypted APFS volume. The script looks like this:
Tacx utility app. Naturally, you will enter the name of your drive, and replace the user code with the one you copied above. Make sure you remove the square brackets.
Applescript To Open Application
- Find a way to launch the script when you need it. There are a bunch of options in my previous post. My preferred option is currently Keyboard Maestro, but an Automator Calendar Alarm, or Lingon X work just as well.
Applescript Run App When Unlocked Mac Pro
Congratulations, you can automatically unlock an APFS volume with AppleScript. Uninstall apps mac os sierra.
Applescript Run App When Unlocked Macbook Pro
Photo by Patrick Lindenberg on Unsplash