Hello there!
I am new on scripting, I created one to create a shortcut from website straight to the Desktop but every time I run it keeps giving the same error: 37:178: execution error: Finder got an error: CanÂt get folder “/Users/administrator/Desktop”. (-1728)
Here’s the script:
#!/bin/bash
Jotform URL
url=“Link”
Loop through all user directories in /Users
for user in /Users/*; do
# Check if it’s a directory and the user profile is not a system folder (like Shared or Guest)
if [ -d “$user” ] && [ -d “$user/Desktop” ] && [ “$(basename $user)” != “Shared” ] && [ “$(basename $user)” != “Guest” ]; then
desktopPath=“$user/Desktop”
shortcutPath=“$desktopPath/Submit Ticket.webloc”
# Check if the desktopPath exists (in case it's not there)
if [ -d "$desktopPath" ]; then
# Create the .webloc file using AppleScript with sudo to ensure elevated permissions
sudo osascript -e "
tell application \"Finder\"
make new internet location file at folder \"$desktopPath\" to \"$url\"
end tell
"
echo "Shortcut created on $user's Desktop"
else
echo "Desktop not found for $user"
fi
fi
done
echo “Shortcuts created on all user desktops!”
Can someone please help me? I’m deploying this through and MDM but I’ve been testing and keeps failing