How to run AppleScript in macOS

Issue #223

Surround script by single quotes

1
2
3
4
5
6
7
8
9
10
11
12
let script = 
"""
tell application "XcodeWay"
activate
end tell
"""

let command = "osascript -e '\(script)'"

let process = Process()
process.launchPath = "/bin/bash"
process.arguments = ["-c", command]

Run as administrator

In terminal, we can

1
2
cd ~/Library
sudo mkdir MyNewFolder

In code, we use with administrator privileges, this when run will ask for password or fingerprint

1
do shell script "mkdir MyNewFolder" with administrator privileges

Comments