Applescript/Launchagent Plist run on Login?

ChickenDenders
New Contributor III

Hey friends --

We have an Applescript that handles the mounting of our network shares. This script is kicked off by a .plist file that lives in /System/Library/LaunchAgents

We've recently upgraded our computers to entirely new hardware, and now it's no longer kicking off on login.

To be honest, I don't know much about writing Applescripts or plist files. This system was in place when I inherited it five years ago, and I've just modified the Applescript to add new network shares as needed. I knew enough to hunt down and extract the plist file to include in our mount script package for machine deployments,which has worked fine for the old trashcans we have, but this new hardware isn't taking it.

We are running 10.15.7 Catalina. Previous machines started on an older OS and were upgraded to Catalina over time. New machines were Catalina straight out of the box. Maybe it's some security thing that was grandfathered in when upgrading... We've been running into that a lot.

Would anybody be able to help with figuring out how to get this thing working again? Or, a different way of doing it?

The mount script itself just lives in /Applications, and works fine if you run it manually. It's just mounting a handful of SMB shares.

Here is the plist file that should be firing off on login:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.company.MountNetworkShares</string>
    <key>ProgramArguments</key>
    <array>
        <string>open</string>
        <string>-a</string>
        <string>/Applications/Mount Network Shares.app</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>
1 REPLY 1

mm2270
Legendary Contributor III

Are you able to post the AppleScript code here, or is the app compiled as run-only? If you can post what the AppleScript is doing, scrubbing out anything confidential, someone might be able to help.

I don't necessarily see anything wrong with the LaunchAgent plist contents. It's straight forward enough. If I had to take a guess, since you said it works if you run the app after being logged in, is that the LaunchAgent is firing off too soon. I've run into situations like that. You can input delays in the AppleScript itself to wait a few seconds after login, or wait until something like the Dock is running for example. Or you might be able to add a delay in the LaunchAgent plist itself.