Australian cloud for business software — built and run in Sydney since 2002

NetLeverage
NetLeverage

Microsoft 365 Apps keeps the old account after a tenant migration or a change of user: resetting activation

Technical article
Troubleshooting

About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.

Microsoft's activation-reset page opens with three tasks it covers: "Tenant to tenant migration", "Repurpose a device for a different user" and "Change the license mode for Microsoft 365 on a device". For each, "you need to clear prior activations of Microsoft 365 apps for enterprise to remove their related licenses and cached Office account information." That returns the apps to a clean state, so they can activate with a different Office account or a different license mode.

Microsoft's page does not cover a server that has been moved or cloned, and the steps below are only the documented clean-up. They apply to the three tasks above.

What the error means

Microsoft 365 Apps keeps three kinds of activation state on a Windows device, all listed on the page:

  • Licence token files and folders. For the licence type called vNext, the folder is %localappdata%\Microsoft\Office\Licenses (Microsoft 365 Apps for enterprise version 1909 or later). For shared computer activation, it is %localappdata%\Microsoft\Office\16.0\Licensing. Legacy licensing is read with ospp.vbs.
  • Cached Office account identities in the registry, under HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Common\Identity, and the licensing key HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Common\Licensing.
  • Credentials: Office entries in Windows Credential Manager, and, on devices that are Microsoft Entra joined, hybrid joined or workplace joined, cached accounts held through Web Account Management (WAM).

The page's locations are per user (%localappdata% and HKEY_CURRENT_USER), so check the clean-up for each Windows user who signed in to Office, on each machine.

Likely causes

Cause What you see How to confirm
Tenant-to-tenant migration Office stays tied to the old tenant's account The account shown in Office is from the old tenant
A device passed to a different user The previous user's account is cached The Office account differs from the new user
Licence mode changed (for example, to shared computer activation) Office keeps the earlier activation cscript ospp.vbs /dstatus and the licence folders show old licences
Managed device holds WAM accounts Clearing the registry is not enough dsregcmd /status shows a joined state

Prove the cause before changing anything

Close all Office applications first, as the page says. Then read, without changing.

  1. Record the licences Office reports. From an elevated command prompt, set the folder for your install. For 64-bit Office on 64-bit Windows:
cd "C:\Program Files\Microsoft Office\Office16"

For 32-bit Office on 64-bit Windows:

cd "C:\Program Files (x86)\Microsoft Office\Office16"
  1. List the licences:
cscript ospp.vbs /dstatus

To keep the listing, create C:\Temp first and run it again with the output sent to a file:

cscript ospp.vbs /dstatus > C:\Temp\dstatus-before.txt

Microsoft notes that "The output could include licenses for multiple applications", and that if it shows "No installed product keys detected" you skip the key-removal steps. Save the output, including "Last 5 characters of the installed product key" for each entry.

  1. Check the device's management state. Run dsregcmd /status in an elevated Command Prompt and read AzureAdJoined, EnterpriseJoined and DomainJoined in the Device State section. Microsoft's table: AzureAdJoined YES with EnterpriseJoined NO and DomainJoined NO is Microsoft Entra joined; NO, NO, YES is Domain Joined; YES, NO, YES is Hybrid AD Joined. A Workplace Joined device shows WorkplaceJoined: YES in the User State section.
  2. List the folders that hold licence tokens. In File Explorer, paste %localappdata%\Microsoft\Office and see whether Licenses and 16.0\Licensing exist. Do not delete anything.
  3. For shared computer activation, find the user's SID: whoami /user in a non-elevated prompt.

Example (illustrative): contoso.com.au moves to a new Microsoft 365 tenant. Four servers, rds01 to rds04, each hold one Windows profile that signed in to Office with the old tenant's account admin@contoso.com.au. On each, cscript ospp.vbs /dstatus lists one licence, so the clean-up is done four times, once per server profile.

Fix

Choose one documented method. Microsoft gives four: the Enterprise (command-line) Microsoft Support and Recovery Assistant, which it recommends for many devices and devices you cannot reach; the Microsoft 365 activation troubleshooter in Get Help on Windows 10 or later; the three scripts OLicenseCleanup.vbs, signoutofwamaccounts.ps1 and WPJCleanUp.cmd; or a manual clean-up. The manual steps follow.

Part 1: remove previous Office activations

  1. Close all Office applications.
  2. Check that C:\Temp\dstatus-before.txt from the earlier step exists and lists the last five characters of each key. If it does not, stop and save it before going on.
  3. Rename the licence token folders, if present, at %localappdata%\Microsoft\Office\Licenses and %localappdata%\Microsoft\Office\16.0\Licensing. Rename each folder instead of deleting it, so there is a way back. Read the Disruptive step: mark below before you run the command.

Disruptive step: the apps lose their licence tokens. Impact: the next start prompts the user to activate. Back-out: close Office, rename any newly created Licenses or Licensing folder with a .new ending, then rename each .old folder back to its original name. A rename fails if the target name already exists.

ren "%localappdata%\Microsoft\Office\Licenses" Licenses.old
ren "%localappdata%\Microsoft\Office\16.0\Licensing" Licensing.old
  1. Remove legacy licences by partial key, using the last five characters you saved. Read the mark below first.

Disruptive step: /unpkey removes the licence for that key; the page's example key is 2WC00, and you must use your own. Impact: the application is unlicensed until it activates again. Back-out: there is no way back from the command; activate again with the account or key. Run it only for the entries you saved and meant to remove, and repeat for each key the listing showed.

cscript ospp.vbs /unpkey:2WC00

Microsoft says the message "Product key uninstall successful" confirms success.

  1. Export, then remove the licensing registry key. Read the mark below first.

Risk: reg delete without /v removes the whole key. HKEY_CURRENT_USER is the hive of the user who runs the command, so run these registry commands as the Office user; if an elevated prompt belongs to a different account, the wrong hive is exported and deleted. The page also warns: "Serious problems might occur if you modify the registry incorrectly. Before you modify it, back up the registry for restoration in case problems occur."

Export first and check that the file exists:

reg export "HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Common\Licensing" C:\Temp\office-licensing-before.reg

Then delete the key:

reg delete "HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Common\Licensing"

To undo it, import the exported file: reg import C:\Temp\office-licensing-before.reg.

Part 2: remove cached account identities

Risk: removing the Identity key clears the cached Office account for that Windows user, in that user's registry hive. For shared computer activation, the page says to remove the same Identity key location under HKEY_USERS\the-user-SID\Software\Microsoft\Office\16.0\Common, using the SID from whoami /user; export that key first in the same way.

Export first and check that the file exists:

reg export "HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Common\Identity" C:\Temp\office-identity-before.reg

Then delete the key:

reg delete "HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Common\Identity"

To undo it, import the exported file: reg import C:\Temp\office-identity-before.reg.

Part 3: Credential Manager

Disruptive step: removing credentials signs Office out of stored accounts. Impact: the user signs in again. Back-out: none; the credentials cannot be restored from here. Write down the entry names before removal. For the registry values below, export that key with reg export first, as above, and import the file to go back.

Open Control Panel, then Credential Manager, then Windows Credentials, and remove each credential listed for Office. The page also says to check for and delete any values under HKEY_CURRENT_USER\Software\Microsoft\Protected Storage System.

Managed devices: WAM accounts and workplace-joined accounts

Microsoft says "There are no steps that you can run manually to clear WAM accounts associated with Office on the device for AADJ and HAADJ devices." Before the script, note the Office accounts the user is signed in to (Settings, then Accounts > Access Work or School, and the account shown in an Office app), so you know what to sign in to again.

Disruptive step: signoutofwamaccounts.ps1 removes the tokens and accounts associated with Office from this Windows user. Impact: the user signs in to Office again. Back-out: none; sign in again with the accounts you noted. Download the script from the link on Microsoft's page, read it, and only then run it as administrator.

Microsoft says "The signoutofwamaccounts.ps1 script will remove the tokens and accounts associated with Office and is safe to run." and that it does not affect the SSO state of the applications or the device state on AADJ and HAADJ devices. It runs only on Windows 10 version 1803 and later.

For a Workplace Joined device, disconnecting the account removes SSO. In Microsoft's words, "All applications in the current Windows session will lose their SSO state, and the device will be unenrolled from management tools and unregistered from the cloud." Disruptive step: use Settings, then Accounts > Access Work or School, select the account and choose Disconnect only when you mean to unenrol the device. Back-out: join or register the device again through your device-management process.

Confirm the fix

  • cscript ospp.vbs /dstatus shows no installed product keys, or only the ones you meant to keep.
  • Starting Word asks for sign-in, and the account chosen is the new one.
  • After activation, cscript ospp.vbs /dstatus shows the expected licence for the new account.
  • On each server in the group, repeat the check to show the clean-up was applied to every profile.

What to watch afterwards

  • Whether a template or image still holds Office state. Microsoft's page does not cover images; check any image that was used on a machine where someone signed in to Office.
  • Users who activated before a licence-mode change. Microsoft lists a licence-mode change as a reason to clear prior activations, so repeat the clean-up for them.
  • Entra devices that still show the old tenant in dsregcmd /status. This clean-up does not change tenant join.
  • .old folders and exported .reg files. Delete them only when the new activation has worked for several days.

Risks and limits

These commands have not been run or lab-tested.

  • Microsoft's reset page is for Microsoft 365 Apps for enterprise on Windows. For Mac it points elsewhere.
  • Microsoft's page does not mention moved or cloned servers, and lists no error text for them. Its References list names separate pages for specific activation errors (for example "Your organization has disabled this device"); those pages are not covered here.
  • ospp.vbs runs through VBScript. The cscript page notes that Windows Server 2025 includes VBScript as a Feature on Demand and that a Windows Server 2028 Preview removes it.
  • Removing a licence or credential has no undo. Everything else here has the back-out beside it.
  • Microsoft's three linked scripts are not described here; read each one before you run it.

Sources