Advice for user-initiated custom PSADT uninstalls

I’m investigating PSADT for use at my university for use in “controlled” lab/classroom (student/multi-user) as well as “uncontrolled” faculty/staff environments.

Let’s say I have an app that needs to deploy per-user customizations (such as using Set-ActiveSetup, Invoke-HKCURegistrySettingsForAllUsers, etc). Then, let’s say the user later manually uninstalls the app via its Add/Remove Programs entry. Is there a way to kick off a custom PSADT uninstall/clean script following (or during) the app’s uninstall from ARP? (for example, to make use of Set-ActiveSetup -PurgeActiveSetupKey)

Maybe I’m thinking about this the wrong way. Is there a better way to do this?

By the way, is there an equivalent function similar to Invoke-HKCURegistrySettingsForAllUsers but for files instead?

Also, can Invoke-HKCURegistrySettingsForAllUsers be used to remove registry keys too? Do I just use “Remove-RegistryKey” within the scriptblock called by this function?

cheers!
Mac

Yes, you can use Invoke-HKCURegistrySettingsForAllUsers to remove registry keys too. Just use “ Remove-RegistryKey ” within the scriptblock called by the function.

For Files, it’s trivial for you to loop through the users’ profile folders to delete/edit files.

Just do this before you install anything and you should be OK.

FYI:
In my custom fork of PSADT we have solved this issue years ago. We hide the ARP entries created by the MSIs/EXEs and create our own custom ARP entry. I could publish the functions but there might be some dependencies that you’d have to resolve.

is your custom form available for use? What is different about it?

thanks

The differences in the Private Fork are logging and about 30+ functions.
The functions that relate to you issue manipulate the ARP entries to hide the real APR entries and creates a new one that points to a CMD that calls the PSADT with the remove -DeploymentType Uninstall
To make this work, during the install it creates a local copy of the PSADT package minus the \Files\ folder to the local C:\ drive.
I don’t mention it because this creates local copies and makes things complicated for some people.
I don’t want to support it.

@That-Annoying-Guy Do you ever share your private fork? It’d be great to start out with yours and avoid reinventing that wheel. Much appreciated. Cheers, Mac.

I won’t share the whole fork because there are parts that are external EXEs and other modifications that you’d have to try to merge with the upcoming 3.8.5 and 4.0 versions.

I am, however, willing to share the ARP functions themselves and how to use them. I’ll have to sanitize them too so this will take time. If you are ok with this, I’ll place them in the Extensions section of these forums and give you a heads up.

@That-Annoying-Guy I wasn’t aware of your fork’s dependencies and needing to clean it up. I’ll check with my team to find out if they’re ok to switch to PSADT away from our custom PS wrapper we developed in-house many years ago. Thanks for the offer.

By the way, what other free & paid tools do you (or anyone else) have in your tool belts you consider vital for packaging? Off the top of my head are VMware Workstation, Sysinternals Process Monitor & Process Explorer & Autoruns & TCPView, WinMerge, WizTree/TreeSize, LogExpert, Registry Finder, HxD, Orca. I’m sure there’s others I’m forgetting.

What tools do you use to track of app installer or config changes? I typically avoid repackaging at all costs, but sometimes figuring out custom configs or settings can be a b*tch. Process Monitor can do this gracefully, but can be a challenge sometimes. AdminStudio Repackager was a defacto standard years ago, but any good free ones out there nowadays? Is the App-V Sequencer still good at doing this? I once saw file & registry change tracking done with PS, but lost track of it.

cheers,
Mac

I was going to give you only the ARP stuff. That has no EXEs or license issues. It’s just references of clients that may still linger in the code.

I mean, if you have to invest any significant time extracting just the ARP stuff, then l’ll check with my team.

I’ll post it and you can judge.

To give you an idea of what’s involved, here is a quick preview of the changes you’d need to do:

  1. Add an environment variable %AdmUtils% to point to a folder on C:\ where you want to copy your PSADT pkg files to make the Custom ARP entries work. If you hate adding environment variable you can change the code to use a PS variable instead. (Dealing with you has made me realize that I should try to remove it as a dependency in my code.)

  2. add the 5 functions to your AppDeployToolkitExtensions.ps1 files that I will post later in the Extensions section of this forum.

  3. add to following to your Deploy-Application.ps1 :

	##*===============================================
	##* VARIABLE DECLARATION
	##*===============================================
	
	[string]$AppMSIName			= 'MSIFileName.MSI' # actual name of the MSI in the \Files folder
    [string]$AppMSICode			= '{ABCDEF00-0000-0000-0000-CHANGE00ME00}' # MSI Product Code of MSI above (used for removal)

		
		
		##*===============================================
		##* INSTALLATION
		##*===============================================
		[string]$installPhase = 'Installation'
		Set-LocalDiskUninstall	#Needed for Custom ARP entry to work

		Execute-MSI -Action Install -Path $AppMSIName -SkipMSIAlreadyInstalledCheck -ContinueOnError $False -LogName "${AppMSIName}_MSI"
		Set-ARPChildOfParent -ArpKeyName $AppMSICode #Hide ARP key created by MSI



		#Set-CustomARP uses \SupportFiles\$InstallName.ico if possible, otherwise uses PSADT icon for Custom ARP entry
		Set-CustomARP
		##*===============================================
		##* POST-INSTALLATION
		##*===============================================

		
		
		
		Set-CustomARP -PkgName $InstallName -Remove
		Set-LocalDiskUninstall -PkgName $InstallName -Remove
		##*===============================================
		##* POST-UNINSTALLATION
		##*===============================================

FYI: With your feedback, I’ll be able to make a better post in the Extensions section for others to understand.

Thanks. I’m not very familiar with Discourse. Can you update me whenever files are posted over there? Thx again.

I was hoping for you to give me feedback before starting the 7 day countdown to locking the post but here you go: Create Custom Programs and Features Entries

I did the code clean up of the dependencies so that it should be easier for you and tested it with 3.8.4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.