Bit of an odd one. Our organisation needs to allow some aspect of local storage access to accommodate work on large files without constantly writing to network drives. They work on these files and then copy them to mounted AD drives. I want to restrict the local files that can be written to. My solution has been to create a launchagent that hides all default folders using chflags hidden and schg on the first login of a user. I have used a launchagent because of the impending threat of login hooks being removed. The issue is that Documents and Downloads never have either the hidden or immutable flag applied and I have no idea why. I have added a delay before the script is run, added the script to the sudoers file so it can be run as root, changed the code, killed finder and kept it killed for the script duration, and even made the script just try to hide documents and nothing works. Any suggestions would be appreciated.
FYI I have tried
find ~ -maxdepth 1 -mindepth 1 -type d -not -name '.*' -not -path "*/Library" -not -path "*/Desktop" -exec sudo chflags schg {} \; -exec sudo chflags hidden {} \;
sudo chflags hidden $HOME/Documents
sudo chflags hidden ~/Documents
sudo chflags -R hidden $HOME
edit: Forgot to mention that manually running the script with the exact same parameters after login works and successfully hides the Documents and Downloads folder. It has to be something on login.