PSADTv4.1.7 - Show-ADTInstallationWelcome Error

I am having an issue with the Show-ADTInstallationWelcome throwing an error. I have narrowed it down to a specific scenario.

Background:
We install Visual Studio Code as a per-user install for the logged on user (a non admin account). Once it is installed into the user profile, we actually run the app with an administrative account opening the non-admin account’s Code.exe file. We also might run the app using the SYSTEM account and often do. The reason for this is that only our Admin accounts and the SYSTEM accounts have rights to install/uninstall applications, whereas our regular accounts do not.

Issue as tested:
When I try to run “Invoke-AppDeployToolkit.exe -DeploymentType Uninstall” from a System or Admin command prompt, with Code.exe running as the non-admin user account, the Show-ADTInstallationWelcome Dialog box appears and everything runs flawlessly.
The issue is when I have Code.exe running as my Admin or the SYSTEM account. When I run the “Invoke-AppDeployToolkit.exe -DeploymentType Uninstall” command from an Admin or SYSTEM command prompt, I get these errors in the Toolkit log…

A closer inspection of the errors:

Relevant PSADT code:

I completely understand this is not a normal practice, to run an app out of another user’s profile, but there are very good reasons it must be done this way. Namely, if you install the app into the Admin account’s profile, the AutoUpdate feature doesn’t work, since the Admin account doesn’t have access to the internet. We need to have the AutoUpdate functional so that we don’t get vulnerabilities that require a repackage, and VSCode updates frequently enough to push us away from packaging that many versions. We are a highly regulated company that has strict regulations to address vulnerabilities.

What you're doing CAN be made to work, but it's a pretty fragile pattern in enterprise terms... user-scope install + running the binary as Admin/SYSTEM out of another user's profile tends to break assumptions in both the app and tooling.

VSCode user-scope specifically disables auto-updates when launched elevated as Admin/SYSTEM. So the "we need auto-updates to avoid repackaging" goal is usually undermined by the way it's being launched and handled.

In highly regulated environments, the more common approach is to disable self-update and instead automate centralized updates (daily/weekly version check -> download -> package -> test -> promote (deploy via Intune/etc.)). That model scales way better than letting endpoints drift via per-user installers.

Whatever's going on here isn't likely to do with your funky setup, but rather something else affecting our client/server process, especially since this error is coming from WPF and not our own code.

Do you have any EPM software within your environment? It's usually the culprit here.

@mjr4077au, what exactly do you mean by “EPM software?” I assume some security software; which we do have, but if it blocks activity, it pops a message up to the user, which I am not seeing. And I am unsure why it would block based upon my next paragraph.

I have narrowed this down. If I remove AllowDeferCloseProcesses from the list of saiwParams and replace it with AllowDefer, the Show-ADTInstallationWelcome appears. If AllowDeferCloseProcesses is active anywhere in the list, I get the error.

**Edit - removed redundant error

EDIT -** Adding that AllowDeferCloseProcesses is only an issue if VSCode is running as an Admin or SYSTEM. When I open VSCode as the logged on user, the AllowDeferCloseProcesses works. Also, AllowDefer fails as well with the same errors if VSCode is running as an Admin or SYSTEM

Can you please provide your entire script in its non-working state? I'll attempt to replicate this locally. As Banshii has said though, what you're doing is pretty fragile.

I would like to just update this topic to provide more information that was just found in testing.

The original issue posed was regarding installing an app (VSCode) into the user profile and then running that app as the system account or as an admin. In this scenario, which was pointed out was not standard practice, when you ran a new install with the app opened as system or admin, the Show-ADTInstallationWelcome prompt would error. All this can be observed in previous comments in this thread.

The new info is that if I install VSCode per-machine and then try to upgrade it with a PSADTv4 script with the app opened as system or admin, I get the same error with Show-ADTInstallationWelcome as I did with the app installed per-user and opened as system or admin. If the app is running as the logged on user, the Show-ADTInstallationWelcome acts fine.

Now I can understand that this could possibly be an excusable error when opening an app within a user’s profile as another user (system or admin), but it is common practice to do this with a per-machine install.

*EDIT: As explained previously in this thread, the scenario is only occurring if I have the parameter AllowDeferCloseApps set on the Show-ADTInstallationWelcome cmdlet. If I remove that parameter and only use AllowDefer, it doesn’t matter if the app is opened using any account (logged on user, System, or admin), it will show the Defer prompt without issue. @mjr4077au - I don’t know how my environment would treat parameters on a cmdlet differently, especially when this was not an issue with v3 in my environment. I don’t rule it out, but to me it seems unlikely.

It is going to be difficult, in my environment, to use the AppDeployToolkit, if the Toolkit cannot close a process opened as system or admin. Our logged on user accounts do not have access to do much, short of running applications. So, it would be a common occurrence for a user to elevate their app to gain the necessary rights, especially when the app is a Developer app, like VSCode.

I don’t recall this being an issue in PSADTv3. Can anyone else replicate this issue, or is it just me?

Here is a screenshot of the error when running the uninstall of VSCode with VSCode running with an admin account…

OK, I just saw that 4.1.8 came out. I tested that with a very cursory simple test, and this version doesn’t seem to have the issue.

Solution, use 4.1.8 or higher if you are having Show-ADTInstallatioWelcome issues.