I’d almost always prefer to tell “System Events” unless there’s something specific to the library you’re targeting (whatever “me” is in this circumstance.)
For executing a shell script I’d prefer targeting System Events.
And re “a better way to do this”: no, I’d argue that a shell script is always the best method when it does the job.
I’m a huge proponent of Unix-first script solutions. Whether it’s supporting Applescript or Keyboard Maestro workflows, what Unix lacks in approachability it more than makes up for in power and cojones.