Command line help. Remove an app from all users desktops

Howard_Trevor
Contributor

Cached Install macOS High Sierra to all the iMacs here and instead of landing in the applications folder it landed on the desktop... every users desktop. Was wondering the command line to remove from all of the users desktops (or an easier way if possible?)
rm -rf “/users/don’t want to have to input every user/desktop/Install macOS High Sierra.app”

8 REPLIES 8

Look
Valued Contributor III

Are you sure it's one every users desktop and not just the same username that was used for packaging?
I wouldn't think it would end up everywhere unless you had FUT and FEU selected.

neil_martin83
Contributor II

rm -rf "/Users/*/Install macOS High Sierra.app" aught to do it.

Howard_Trevor
Contributor

@neil.martin83 Ran the command through ard while monitoring a students machine, command said it was successful but it was still on the desktop.

@Look I didn’t do the initial package build so I’m gunna go ahead and say those were selected. And now I’m running clean up.

mm2270
Legendary Contributor II

The command above doesn't include "Desktop" in the path. If the installer really landed on their Desktops, and not in the root of their home folder, then you have to include that. Also, I don't know how well it works to enclose the path in double quotes when using a * wildcard. You could run into issues with that. You can try this:

rm -rf /Users/*/Desktop/Install macOS High Sierra.app

But truthfully something like the following might be more reliable

#!/bin/bash

for u in $(ls /Users); do
    if [ -d "/Users/$u/Desktop/Install macOS High Sierra.app" ]; then
        rm -R "/Users/$u/Desktop/Install macOS High Sierra.app"
    fi
done

You could even include an echo in there to confirm it found it on any user's desktops and deleted it. That would show up in the policy log as a confirmation of what it did.

Cornoir
Contributor II

Just use the JSS Restricted Software option to delete ALL instances of Install macOS High Sierra.app, then push it out again to the /Applications folder.

Howard_Trevor
Contributor

@Cornoir Wow, never even thought of running it through there. Does it have to be clicked on before it disappears?

mm2270
Legendary Contributor II

@Howard.Trevor

Does it have to be clicked on before it disappears?

Yes, any application or process that's set up in Restricted Software only gets removed (if that option is enabled) when it's run. It won't remove it silently in the background if the clients aren't trying to launch the software. So in my mind, it's not really a great option to use. I would probably use a scripted method of removing it.

Howard_Trevor
Contributor

@mm2270 yeah I thought so. I do like the idea of allowing the students to do my work for me. We all know if there’s something on the desktop they are going to click on it.

But I will end up giving your scripts a try. I ran into issues with the * in my previous scripts, so it looks like your second option should do what I need.

I really appreciate your help buddy.