DEV Community

Matthew J. Moore
Matthew J. Moore

Posted on

Checking Office activation from the command line with ospp.vbs

Everyone knows slmgr for Windows activation, but fewer people know Office has its own equivalent. It's called ospp.vbs and it's been sitting in the Office folder this whole time.

I use it constantly when someone tells me Word says "Unlicensed Product" and the File, Account page isn't giving any useful detail.

Where it lives

For a normal 64-bit Office install (Office 2016 and later all use the Office16 folder):

cd "C:\Program Files\Microsoft Office\Office16"
Enter fullscreen mode Exit fullscreen mode

If you're on 32-bit Office on 64-bit Windows, it's under C:\Program Files (x86)\Microsoft Office\Office16 instead. Like slmgr, run it from an admin prompt and through cscript so the output prints in the console.

/dstatus: what's installed and is it licensed?

cscript ospp.vbs /dstatus
Enter fullscreen mode Exit fullscreen mode

This lists every Office license on the machine, with the name, the license status and the last five characters of each installed key. Two things I look for straight away:

  • More than one license block. Very common on laptops that came with a Microsoft 365 trial. Someone installs Office 2021 on top and now there are two products fighting each other. This is the number one cause of "Unlicensed Product" I see.
  • The LICENSE NAME line. It tells you whether you're on a retail or volume license, which matters for how it should be activated.

/inpkey and /act: put a key in and activate

cscript ospp.vbs /inpkey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
cscript ospp.vbs /act
Enter fullscreen mode Exit fullscreen mode

Same idea as slmgr /ipk then /ato on Windows. If /act fails, it gives you an error code, so note it down.

/unpkey: remove an old key

If /dstatus shows a leftover license you don't want (an expired trial, an old key), remove it using the last five characters shown:

cscript ospp.vbs /unpkey:AB123
Enter fullscreen mode Exit fullscreen mode

Do this before activating the one you actually want, otherwise Office can keep checking the wrong license.

A caveat

ospp.vbs is most useful for volume and standalone retail installs. Microsoft 365 subscriptions are licensed through your account sign-in, so for those the answer is usually on the File, Account page rather than in here.

My usual order

  1. /dstatus to see everything that's installed.
  2. Remove anything that shouldn't be there with /unpkey, or uninstall the extra Office product from Settings, Apps.
  3. Quick Repair from Settings, Apps if things still look off.
  4. /inpkey and /act for the license you actually want.

Nothing fancy, but it turns a vague "Unlicensed Product" banner into something you can actually work with.

Top comments (0)