Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSIX post Uninstallation event to revert system configuration #4989

Open
mike7ang1rdz opened this issue Dec 20, 2024 · 1 comment
Open

MSIX post Uninstallation event to revert system configuration #4989

mike7ang1rdz opened this issue Dec 20, 2024 · 1 comment
Labels
area-Deployment Issues related to packaging, installation, runtime (e.g., SelfContained, Unpackaged) needs-author-feedback

Comments

@mike7ang1rdz
Copy link

Hello

Need help with MSIX post-uninstallation tasks

After uninstalling an MSIX package, I need to revert some registry changes and clear temporary files in the user's temp folder.

Are there some examples to do these operations after uninstallation? :

  • uninstallation events to revert specific registry keys
  • Methods to clear temporary files in the temp folder

Thanks!

@DrusTheAxe
Copy link
Member

What registry changes? Does ApplicationData.LocalSettings meet your needs?

By "user's temp folder" I assume you mean %USERPROFILE%\AppData\Local\Temp? Why not ApplicationData.TemporaryFolder?


Are you a DesktopBridge app? (aka RuntimeBehavior=packagedClassicApp aka EntryPoint=windows.fullTrustApplication or windows.partialTrustApplication). DesktopBridge apps get i/o virtualization for some registry and filesystem locations (usually HKCU + %USERPROFILE%). If you're writing to these locations the changes will be automagically removed when the package is removed for a user. See Flexible virtualization.

You can also use ApplicationData.TemporaryFolder to get a temp file location or ApplicationData.LocalSettings for structured data (registry-like, but not Registry APIs). There's also ApplicationData.LocalFolder and ApplicationData.LocalCacheFolder for not-so-temporary filesystem locations for your package family per-user which are equally auto-removed when the package family is removed for a user.

(.TemporaryFolder can be emptied by Disk Cleanup Wizard and like mechanisms, whereas .Local[Cache]Folder doesn't)

P.S. WinAppSDK's Microsoft.Windows.Storage.ApplicationData provides an enhanced experience over the OS API, e.g. ApplicationData.Current.TemporaryPath is equivalent to ApplicationData.Current.TemporaryFolder.Path but more efficient and convenient :-)

Generally if you're a packaged app the recommended API for data storage is ApplicationData, not RegOpenKeyEx(), GetTempPath() or other APIs. Or if you're a DesktopBridge app such classic Win32 APIs partying on per-user locations are redirected to managed storaged associated with the user+packagefamily (unless you disable the i/o virtualization) and thus automagically deleted when the package is removed for a user.

If you find yourself needing to write outside ApplicationData and virtualized data locations then no, there's currently no mechanism to 'delete other data on uninstall'. This enhancement request is in our backlog and being tracked via Issue #2779: Uninstall/Reset/Repair Tasks #2779. If this interests you please share your feedback in the issue with details about your scenario to help us take into account in our planning and design efforts.

@RDMacLachlan RDMacLachlan added needs-author-feedback area-Deployment Issues related to packaging, installation, runtime (e.g., SelfContained, Unpackaged) and removed needs-triage labels Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Deployment Issues related to packaging, installation, runtime (e.g., SelfContained, Unpackaged) needs-author-feedback
Projects
None yet
Development

No branches or pull requests

3 participants