Posted on 03-19-2024 05:00 PM
Hello, I've found this script and it is working fine (to create the file). But when trying to open the actual file [link] from the desktop, it gives an error.
I noticed that the permissions show this file as being owned by ROOT, since it is populated through a script via Jamf, but I'm not sure if that's the issue. If I try to create my own webloc file by dragging a webpage from Safari to my Desktop, that works just fine. But not one created by this script.
Posted on 03-20-2024 05:47 AM
You may have more luck making the file an internet shortcut... Essentially this is a file of type "FileName.url" with content:
[InternetShortcut]
URL=https://targetwebsite.website
We create these in /Library and link them to the users dock, but putting it on the desktop should still work... The other option I can think of is to generate the file as the user using a function like:
ACTIVE_USER=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ && ! /loginwindow/ { print $3 }' )
# Function to run command as user
run_as_user() {
if [[ "${ACTIVE_USER}" != "loginwindow" ]]; then
User_ID=$(id -u "$ACTIVE_USER")
launchctl asuser "$User_ID" sudo -u "${ACTIVE_USER}" "$@"
else
echo "no user logged in"
exit 0;
fi
}
Posted on 03-20-2024 06:19 AM
@janzaldua Here's the post I made a while back with a script to create a .webloc that properly sets permissions: https://community.jamf.com/t5/jamf-pro/can-t-create-composer-webloc-desktop-item/m-p/267843/highligh...
03-21-2024 01:44 PM - edited 03-21-2024 01:48 PM
Thank you! I believe this is working. It seems to be a permissions issue. Appreciate you!
Edit: I may have spoken too soon. When I tried to replace the string with my own link that I need to deploy, I get the same error. "The document could not be opened."
To give some context, the link/url is an Internal Service Now link.
Posted on 03-21-2024 06:59 PM
@janzaldua What happens if you try replacing the string with some other web site instead of your Service Now link? I'm curious if that allows you to create a working .webloc.
Posted on 03-21-2024 10:33 PM
When using your original script, it worked fine actually. But once I changed the URL to my own (Service Now link), it wouldn't open and I would get the error. So I assume it doesn't like my service now URL, for some reason...