Why not use a package, script, application to uninstall the app from user’s profile space? There are limitations when it comes to executing a TS to address user context based scenarios.
Task Sequence can't find file in users AppData folder
Hi all - I'm trying to uninstall a program (let’s call it XYZ) that is EXE based, not MSI. It wasn't originally installed by SCCM and installed by end users into their own user profiles. The uninstaller (Uninstall.exe) is located in the user’s profile: 'C:\Users\%randomuser%\AppData\Roaming\XYZ Program.' There is one task sequence step as a ‘Run Command.’ However, as it's a Task Sequence, it runs in system context. When I specify %APPDATA%\XYZ Program in the 'Start in' folder, it actually points to C:\Windows\system32\config\systemprofile because the task sequence runs in the system context. Of course, it fails as it can't find Uninstall.exe which is in the user’s profile.
What we need is to have the run command find the uninstall.exe where it is found in any users appdata roaming folder. Questions:
- Perhaps I can adjust my environmental variables for the 'Start in' section? I've scoured the net and can't find anything like this. Don't think it's possible.
- If the Task Sequence can't search other users appdata\roaming folders, is there a PowerShell command I can use and add it as a step in the task sequence to run this one liner against users’ profile? Scour each users roaming folder and then run the command if there is a match.
Thanks!
3 answers
Sort by: Most helpful
-
-
AlexZhu-MSFT 6,116 Reputation points Microsoft Vendor
2021-09-24T01:00:57.297+00:00 Hi,
If we want to uninstall a per-user application, it seems we can use powershell to locate the uninstaller first, add the silent switch and run the uninstallation command. Here's the sample script to illustrate how it works and you may modify it and test in your environment.
$a = Get-ChildItem -Path c:\users\ -Recurse -force -ErrorAction SilentlyContinue | ? {$_.name -like '*uninst.exe*' -and $_.directoryname -like '*youdao*'} $command = $a.directoryname + "\" + $a.name invoke-command $command
test with SYSTEM account in the client computer
add a run Powershell step to the task sequence (since the script is simple, we can enter it directly without creating a package)
Alex
If the response is helpful, please click "Accept Answer" and upvote it. -
net1994 131 Reputation points
2021-09-24T17:46:25.113+00:00 Hi Alex,
Thanks so much. Here is additional info. I already know the path and uninstall exe that needs to be used: %APPDATA%\Juniper Networks\Setup Client\uninstall.exe /silent-1
Questions:
- As I know the path where the uninstaller is, can I put that directly into the PS script?
- If I copy the PS script directly into the task sequence step (not as a powershell ps1 file), will it be able to run as we are trying to perform an action within the users profile, however Task Sequences run in system context?