LaunchDaemon assistance I have the following .sh script that deletes Sierra, upon download, from the App store. This applies to any user on mac osx 10.10 or 10.11. 

However can someone add the code so that the app (sierra.app) actually deletes as soon as it starts downloading as opposed to when its finished downloading which is what it presently does.

In addition the osascript display message does not display once it has deleted. How can I get that to work?

Here is the script.

#!/bin/bash

Version=$(sw_vers | grep ProductVersion | tail -c 7 | cut -d . -f 2)    

if [[ $Version -ge 12 ]]
then  
launchctl unload /Library/LaunchDaemons/net.infor.sierra.plist
rm -f /Library/LaunchDaemons/net.infor.sierra.plist
rm -f /usr/local/bin/sierra.sh
exit 0

else
rm -rf /Applications/Install\ macOS\ Sierra.app/
osascript -e 'tell app "System Events" to display dialog "macOS sierra is not allowed on computers at this time." with title "Technology Notice" buttons {"OK"} default button "OK" giving up after 30'
fi


Here is the plist.

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com    /DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
&lt;key&gt;Label&lt;/key&gt;
&lt;string&gt;net.infor.sierra.plist&lt;/string&gt;
&lt;key&gt;ProgramArguments&lt;/key&gt;
&lt;array&gt;
&lt;string&gt;/usr/local/bin/sierra.sh&lt;/string&gt;
&lt;/array&gt;
&lt;key&gt;KeepAlive&lt;/key&gt;
&lt;dict&gt;
&lt;key&gt;PathState&lt;/key&gt;
&lt;dict&gt;
    &lt;key&gt;/Applications/Install macOS Sierra.app/&lt;/key&gt;
    &lt;true/&gt;
&lt;/dict&gt;
&lt;/dict&gt;
&lt;key&gt;OnDemand&lt;/key&gt;
&lt;true/&gt;
&lt;/dict&gt;
&lt;/plist&gt;
not really an answer, but maybe a hint as to where to go next...

To catch it earlier, you'd have to intercept it at the download folder. I'd guess the folder name will be different for everybody - mine is at
/private/var/folders/nc/c83zpk8x7kd9qrxrd3nnbfym0000gn/C/com.apple.appstore 

You can find it from the App Store app > Debug > Show Download Folder... if you enable the debug menu with
defaults write com.apple.appstore ShowDebugMenu -bool true