{"id":293,"date":"2026-09-01T09:00:54","date_gmt":"2026-09-01T16:00:54","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/insidemsix\/?p=293"},"modified":"2026-08-27T23:24:00","modified_gmt":"2026-08-28T06:24:00","slug":"msix-servicing-while-in-use","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/insidemsix\/msix-servicing-while-in-use\/","title":{"rendered":"Servicing While In Use and ERROR_PACKAGES_IN_USE"},"content":{"rendered":"<p>How does MSIX service a package while it&#8217;s in use?<\/p>\n<p>Simple: It doesn&#8217;t.<\/p>\n<p>A core principle of MSIX servicing is:<\/p>\n<p><strong>Do not service a package while it&#8217;s in use.<\/strong><\/p>\n<p>Deployment provides several ways to deal with that constraint. Options range from terminating applications to deferring servicing until the package is no longer in use.<\/p>\n<h2>How hard can it be?<\/h2>\n<p>&#8216;Servicing a package&#8217; means any deployment activity modifying software, including update, remove, repair and other operations.<\/p>\n<p>Altering installed software can be highly disruptive if the software is in use. Executables and DLLs may be mapped into running processes. File and registry writes may be in progress. Processes may be connected through COM, named pipes, or other IPC mechanisms.<\/p>\n<p>There <em>are<\/em> ways to handle it, but <em>how<\/em> is unique to each application. There&#8217;s no generally applicable solution for all applications. Other than &#8220;Don&#8217;t do that&#8221;.<\/p>\n<p>How hard can it be? Hard enough for any single app. Across the spectrum of apps on Windows? Very.<\/p>\n<p>One size can&#8217;t fit all, so MSIX offers several options.<\/p>\n<h2>Default Behavior: Fail with ERROR_PACKAGES_IN_USE<\/h2>\n<p>In the simplest case, Deployment rejects a request to service a package while in use. For example, assume <code>Contoso.PointOfSale-v1.msix<\/code> declares an application using <code>Contoso.PointOfSale.exe<\/code>. The application is running. A <a href=\"https:\/\/devblogs.microsoft.com\/insidemsix\/deployment-operations-requests-and-queue\/\">deployment request<\/a> to update the package to v2 will detect the <code>Contoso.PointOfSale.exe<\/code> process is using the v1 package and fail the request e.g.<\/p>\n<pre><code class=\"powershell\">Add-AppxPackage 'C:\\Packages\\Downloads\\Contoso.PointOfSale-v2.msix'\n...\nAdd-AppxPackage : Deployment failed with HRESULT: 0x80073D02, The package could not be installed because resources it modifies are currently in use.\n...\n<\/code><\/pre>\n<p>Deployment returns <a href=\"https:\/\/learn.microsoft.com\/windows\/win32\/appxpkg\/troubleshooting\">ERROR_PACKAGES_IN_USE (0x80073D02)<\/a>, indicating the deployment operation cannot proceed because it would service a package while in use.<\/p>\n<h2>Option 1: Shut Down the Application<\/h2>\n<p>One option is to quit the app using the v1 package to unblock the update.<\/p>\n<p>Another option is to terminate the app via <a href=\"https:\/\/learn.microsoft.com\/windows\/win32\/api\/processthreadsapi\/nf-processthreadsapi-terminateprocess\">TerminateProcess()<\/a>, <a href=\"https:\/\/learn.microsoft.com\/windows-server\/administration\/windows-commands\/taskkill\">TASKKILL<\/a>, <a href=\"https:\/\/learn.microsoft.com\/windows\/msix\/msix-troubleshooting-guide#package-installation-blocked-because-the-app-is-in-use\">PowerShell cmdlets<\/a> or similar utilities.<\/p>\n<p><a href=\"https:\/\/learn.microsoft.com\/uwp\/api\/windows.management.deployment.packagemanager\">PackageManager<\/a> provides an option to do exactly this: <code>ForceTargetAppShutdown<\/code>.<\/p>\n<pre><code class=\"csharp\">var packageUri = new Uri(\"C:\\\\Packages\\\\Contoso.PointOfSale-v2.msix\");\nvar options = new AddPackageOptions();\noptions.ForceTargetAppShutdown = true;\nvar packageManager = new PackageManager();\nvar result = await packageManager.AddPackageByUriAsync(packageUri, options);\n<\/code><\/pre>\n<p>Or use the similarly named <code>-ForceTargetApplicationShutdown<\/code> option with the <a href=\"https:\/\/learn.microsoft.com\/powershell\/module\/appx\/add-appxpackage?view=windowsserver2025-ps\">Add-AppxPackage<\/a> PowerShell cmdlet:<\/p>\n<pre><code class=\"powershell\">Add-AppxPackage 'C:\\Packages\\Contoso.PointOfSale-v2.msix' -ForceTargetApplicationShutdown\n<\/code><\/pre>\n<p>This deployment request checks for processes using the target package. It shuts them down, forcibly if necessary, to unblock the deployment operation.<sup>1<\/sup><\/p>\n<h2>Option 2: Defer the Update<\/h2>\n<p>Failure and <code>TerminateProcess()<\/code> are rather stark options. Not every process can quit or be terminated harmlessly. For example, it would be disruptive if <code>Terminal<\/code> is running a batch job that takes hours to complete.<\/p>\n<p>MSIX offers an opt-in solution in <code>AppxManifest.xml<\/code>: <a href=\"https:\/\/learn.microsoft.com\/uwp\/schemas\/appxpackage\/uapmanifestschema\/element-uap17-updatewhileinuse\"><uap17:updatewhileinuse>defer&lt;\/><\/uap17:updatewhileinuse><\/a>.<\/p>\n<p>When a package sets <code>uap17:UpdateWhileInUse<\/code><sup>2<\/sup> to <code>defer<\/code>, Windows defers the update rather than shutting down the application. This also takes precedence over force-update options such as <code>ForceTargetAppShutdown<\/code>: Windows ignores those options for a package that declares deferred update behavior. Windows defers the update until the package is no longer in use. Deployment completes it at the next opportunity.<\/p>\n<p>Alternatively, deferred registration can be requested at runtime for an individual deployment operation via <a href=\"https:\/\/learn.microsoft.com\/uwp\/api\/windows.management.deployment.addpackageoptions.deferregistrationwhenpackagesareinuse\">DeferRegistrationWhenPackagesAreInUse<\/a>. If a package is currently in use, registration is delayed and completed when the package can be updated, such as on the application&#8217;s next activation.<\/p>\n<p>For example, using the <code>PackageManager<\/code> API:<\/p>\n<pre><code class=\"csharp\">var packageUri = new Uri(\"C:\\\\Packages\\\\Contoso.PointOfSale-v2.msix\");\nvar options = new AddPackageOptions();\noptions.DeferRegistrationWhenPackagesAreInUse = true;\nvar packageManager = new PackageManager();\nvar result = await packageManager.AddPackageByUriAsync(packageUri, options);\n<\/code><\/pre>\n<p>or the <code>Add-AppxPackage<\/code> PowerShell cmdlet:<\/p>\n<pre><code class=\"powershell\">Add-AppxPackage 'C:\\Packages\\Contoso.PointOfSale-v2.msix' -DeferRegistrationWhenPackagesAreInUse\n<\/code><\/pre>\n<p>Many apps, packaged and unpackaged, offer this sort of update experience. When an update is available, the app offers an &#8216;Update now&#8217; option: &#8220;Hey buddy, I&#8217;ve got an update. If you want it now, great. If not, I&#8217;ll take care of it later when you&#8217;re not using me.&#8221;<\/p>\n<p>This gives developers two ways to request deferred updates: a package can opt in to the behavior through its manifest, or an individual deployment request can opt in through an API or tool.<\/p>\n<h3>Detect a Deferred Update<\/h3>\n<p>Can you detect if a package has an update deferred?<\/p>\n<p>Yes!<\/p>\n<p><a href=\"https:\/\/learn.microsoft.com\/windows\/windows-app-sdk\/api\/winrt\/microsoft.windows.management.deployment.packagedeploymentmanager.ispackageregistrationpending\">PackageDeploymentManager.IsPackageRegistrationPending<\/a> returns true if the package family has a pending (previously deferred) update for the current user.<\/p>\n<p><a href=\"https:\/\/learn.microsoft.com\/windows\/windows-app-sdk\/api\/winrt\/microsoft.windows.management.deployment.packagedeploymentmanager.ispackageregistrationpendingforuser\">PackageDeploymentManager.IsPackageRegistrationPendingForUser<\/a> returns true if the package family has a pending (previously deferred) update for the specified user. As usual, admin privilege is required if the specified user isn&#8217;t the caller.<\/p>\n<h2>Defer Removal While In Use<\/h2>\n<p>Remove operations <a href=\"https:\/\/devblogs.microsoft.com\/insidemsix\/remove-is-not-uninstall\/\">implicitly have &#8216;Force&#8217; semantics<\/a> so they have no explicit [ForceTargetApplicationShutdown] option.<\/p>\n<p>But what if an application is busy?<\/p>\n<p>MSIX offers similar deferred behavior for removal via <a href=\"https:\/\/learn.microsoft.com\/uwp\/api\/windows.management.deployment.removaloptions\">PackageManager.RemovePackageAsync<\/a>(packageFullName, <a href=\"https:\/\/learn.microsoft.com\/uwp\/api\/windows.management.deployment.removaloptions\">RemovalOptions.DeferRemovalWhenPackagesAreInUse<\/a>):<\/p>\n<pre><code class=\"csharp\">var packageManager = new PackageManager();\nstring packageFullName = \"Contoso.PointOfSale_2.3.4.5_arm64__1234567890abc\";\nvar options = RemovalOptions.DeferRemovalWhenPackagesAreInUse;\nvar result = await packageManager.RemovePackageAsync(packageFullName, options);\n<\/code><\/pre>\n<p>If the package is in use, Deployment marks it for removal at the next opportunity<sup>3<\/sup> <em>instead<\/em> of terminating processes to unblock the removal. The algorithm is effectively:<\/p>\n<pre><code>IF package is in use\n    IF options.DeferRemovalWhenPackagesAreInUse is set\n        Mark the package for deferred removal\n        return SUCCESS\n    ELSE\n        Ask app to shutdown\n        IF app still running\n            TerminateProcess()\n        ENDIF\n        IF app still running\n            return ERROR_PACKAGES_IN_USE\n        ENDIF\n    ENDIF\nENDIF\n\n\/\/ package is not in use\nRemove the package\nreturn SUCCESS\n<\/code><\/pre>\n<hr \/>\n<p><sup>1<\/sup> Processes are requested to shut down and, if necessary, may be forcibly terminated via <code>TerminateProcess()<\/code>.<\/p>\n<p><sup>2<\/sup> <code>uap17:UpdateWhileInUse<\/code> requires Windows 11 version 24H2 (build 26100) or later.<\/p>\n<p><sup>3<\/sup> Deployment completes a deferred removal when it gets an opportunity after the package is no longer in use. Depending on how the package is used, that may not occur until a later user session.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How does MSIX service a package while it&#8217;s in use? Simple: It doesn&#8217;t. A core principle of MSIX servicing is: Do not service a package while it&#8217;s in use. Deployment provides several ways to deal with that constraint. Options range from terminating applications to deferring servicing until the package is no longer in use. How [&hellip;]<\/p>\n","protected":false},"author":911,"featured_media":101,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[8,9,3,29,6,18,15],"class_list":["post-293","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-msix","tag-architecture","tag-code","tag-deployment","tag-packagedeploymentmanager","tag-packagemanager","tag-powershell","tag-remove"],"acf":[],"blog_post_summary":"<p>How does MSIX service a package while it&#8217;s in use? Simple: It doesn&#8217;t. A core principle of MSIX servicing is: Do not service a package while it&#8217;s in use. Deployment provides several ways to deal with that constraint. Options range from terminating applications to deferring servicing until the package is no longer in use. How [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/insidemsix\/wp-json\/wp\/v2\/posts\/293","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/insidemsix\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/insidemsix\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/insidemsix\/wp-json\/wp\/v2\/users\/911"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/insidemsix\/wp-json\/wp\/v2\/comments?post=293"}],"version-history":[{"count":1,"href":"https:\/\/devblogs.microsoft.com\/insidemsix\/wp-json\/wp\/v2\/posts\/293\/revisions"}],"predecessor-version":[{"id":297,"href":"https:\/\/devblogs.microsoft.com\/insidemsix\/wp-json\/wp\/v2\/posts\/293\/revisions\/297"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/insidemsix\/wp-json\/wp\/v2\/media\/101"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/insidemsix\/wp-json\/wp\/v2\/media?parent=293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/insidemsix\/wp-json\/wp\/v2\/categories?post=293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/insidemsix\/wp-json\/wp\/v2\/tags?post=293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}