Uninstall app for user, then install app for system?

With SCCM, I need to install an app for system (all users), but first remove any version of that app that was installed for user. Because pre-SCCM that's how the software was installed (manually). How do I put together a deployment that combines the two actions of uninstalling the app for user, then installing the app for system?

I think I want to use supersedence, so I set up two apps, one with the install that runs for system, and one with a dummy install and an uninstaller that is set to run for user. But in testing it leaves behind the old app, it doesn't even try to uninstall it, as if the supersedence is being ignored. Does anyone have experience with this situation - should supersedence still work when the uninstall action is for user but the install action is for system? I have a working uninstall script, that's not the problem. The detection methods for both deployment types are based on file existence; the install folder for this software is different when you install for single user vs all users. Addendum: I checked ccmcache and it does not appear to be caching the uninstaller, which is further indication that it's not even trying to run the uninstaller for supersedence.

Another way might be to set up the 'uninstall for user' action as an install instead, and then chain the two installs together using either App Groups, or a task sequence, or a dependency. I've tested that method successfully but I don't want to do it that way due to problems such as it leaving behind an entry in Software Center for the uninstalled app.

edit: My whole assumption was wrong, and the problem is not with supersedence which turns out to work fine in this situation.

I should have thought to test the uninstall exclusively. Turns out to be a problem with the detection method for the uninstall (for user). I cannot include a user-based environment variable such as %LOCALAPPDATA% in the detection method because it doesn't get evaluated properly, possibly because detection is evaluated in system context instead of user? So that stinks. How do I detect a single-user install then?

Posted Feb 28, 2022, 5:35 AM UTC · edited

107
danmanthetech•

Two deployment types in same app

  • one uninstalls in user context with a requirement of the presence of the user installed app

  • one installs app as system but has dependency on the other DT

4
VexingRaven•

Yeah this is the only way I've found that's a workable way to chain together user-based and system-based actions.

1
gandraw•

As you noticed, file based detection rules don't work for user installs. Registry and script based detection rules work however.

3
BoxofoldcablesOP•

Turning the detection of the uninstall app into a powershell script seems to be working, it is able to use the %LOCALAPPDATA% environment variable successfully.

uninstall for user > detection method > custom script > PowerShell

$appPath = $Env:LOCALAPPDATA + '\additionalpath\filename.ext' if (Test-Path $appPath) {write-host "success"}

2
gandraw•

If you'd like please send a frowny-face in the console about this. I've already done this a while ago but more opinions would maybe help. And I think it's an oddity that file detection doesn't work correctly in this case.

2
ozzymanii•

I've never done this, but I bet there is a registry key that gets created when the user does the install. On a machine that has had it installed for the user, scan the registry for any key that references the software. That will tell you where that key is. Then you can make a powershell script that looks for that key for every user on the system. If it is found... then you can do your uninstall.

That's all I have.

2
vickardis•

Create an HKCU registry key, that works.

1