Microsoft 365 Activation via CMD Command Guide
In this article
To activate Microsoft 365 using the Command Prompt (CMD), you must use the ospp.vbs script located within the Office installation folder to manage product keys and activation states. This process allows administrators or users to manually input a product key, remove old license fragments that cause activation conflicts, and force the software to communicate with the activation servers without using the standard graphical user interface. This is particularly useful when the Office app freezes during activation or when you are transitioning between different subscription types.
What You'll Need
- A computer running Windows with Microsoft 365 installed.
- Administrative privileges on the local machine (required to run CMD as administrator).
- A valid, genuine Microsoft 365 product key or an active account subscription linked to your email.
- A stable internet connection to reach the Microsoft activation servers.
Step-by-Step
- Open Command Prompt as Administrator: Click the Start menu, type "cmd" into the search bar. Right-click on "Command Prompt" and select "Run as administrator". This is a critical step; if you run CMD as a standard user, the system will return an "Access Denied" error when attempting to modify license files.
- Locate the Office Installation Folder: You must navigate to the folder containing the
ospp.vbsscript. The path varies depending on whether you installed the 32-bit or 64-bit version of Office and your Windows architecture.
For 64-bit Office on 64-bit Windows, the path is usually:cd "C:\Program Files\Microsoft Office\Office16"
For 32-bit Office on 64-bit Windows, the path is usually:cd "C:\Program Files (x86)\Microsoft Office\Office16"
Type the appropriatecd(change directory) command and press Enter. Note that labels and folder names may differ slightly depending on the specific version or region of your installation. - Check Current Activation Status: Before applying a new key, it is helpful to see the current status of your licenses. Type the following command and press Enter:
cscript ospp.vbs /dstatus
This command will display the current license status and the last five characters of any installed product keys. This helps you identify if there are multiple conflicting licenses installed on the machine. - Remove Old Product Keys (Optional but Recommended): If you are seeing errors like "Another account is already signed in," you should remove the old key fragments. Look at the output from the previous step and find the 5-character key ID. Type the following command, replacing XXXXX with those five characters:
cscript ospp.vbs /unpkey:XXXXX
Press Enter. Repeat this for every old key listed to ensure a clean slate. - Install the New Product Key: Now, input your genuine Microsoft 365 product key using the following command, replacing YYYYY-YYYYY-YYYYY-YYYYY-YYYYY with your actual 25-character key:
cscript ospp.vbs /inpkey:YYYYY-YYYYY-YYYYY-YYYYY-YYYYY
Press Enter. You should see a message confirming that the product key was installed successfully. - Trigger Immediate Activation: To force the software to activate immediately rather than waiting for the next app launch, run the activation command:
cscript ospp.vbs /act
Press Enter. The system will now contact the Microsoft servers to validate the key. - Verify Success: Run the status command one last time to ensure the product is now marked as "LICENSED":
cscript ospp.vbs /dstatus
Common Mistakes
The most frequent error is failing to run the Command Prompt as an administrator. Without elevated permissions, the ospp.vbs script cannot write to the system registry or the Office installation folder, resulting in a generic error or a "Permission Denied" message. Another common mistake is navigating to the wrong directory. Users often try to run the command from the default C:\Users\Username path; however, the script only works if the CMD focus is inside the specific Office16 folder. If you receive a message saying "The system cannot find the file specified," it means you are in the wrong folder.
Additionally, users often confuse the 32-bit and 64-bit paths. If you are unsure which one you have, try the Program Files path first; if that folder does not exist or doesn't contain the Office16 folder, switch to Program Files (x86). Finally, avoid typing the product key with spaces or dashes if the command prompt is giving you syntax errors, although the standard format usually works.
Tips
To speed up the process in the future, you can copy and paste the directory paths from a text file rather than typing them manually, as the paths are long and prone to typos. If you are managing multiple machines, you can create a simple .bat file containing these commands to automate the cleanup and activation process, provided the file is executed with administrative rights.
Always ensure that your Windows Update is current before attempting CMD activation. Sometimes, the activation servers require the latest security certificates to be present on the OS to establish a secure handshake. If you are using a corporate network, ensure that your firewall is not blocking the specific ports used by the Microsoft Office Software Protection Platform, as this will cause the /act command to time out.
Troubleshooting
If the activation does not go as planned, start with the simplest checks. First, restart your computer and ensure you have a functioning internet connection. If you are using a VPN, disable it, as Microsoft's activation servers sometimes flag VPN IP addresses as suspicious, which can block the activation request.
If you receive an error stating that the product key is already in use or has reached its limit, double-check that you are using the correct key for your specific version of Microsoft 365. If you have transitioned from a one-time purchase (like Office 2019) to a 365 subscription, the old license remnants are the most likely culprit. Use the /unpkey command mentioned in the step-by-step section to remove every single single existing key before trying to install the new one again.
In cases where the ospp.vbs script itself fails to run or returns a script error, check if your system's default script host is set correctly. You can try calling the script specifically with cscript (as shown in the steps) rather than wscript, as cscript is designed for command-line output and is more stable for this specific task. If all else fails, sign out of your Microsoft account within any Office app (like Word), restart the machine, and then attempt the CMD sequence again.
Frequently Asked Questions
Can I use this method to activate Office for free?
No. This method is a way to manage and input legitimate licenses via the command line; it does not bypass the requirement for a genuine product key or subscription.
What does the "Office16" folder name mean?
Despite the number, the "Office16" folder is used for Microsoft 365, Office 2016, Office 2019, and Office 2021. It refers to the internal versioning of the software architecture.
Is it safe to delete product keys using the /unpkey command?
Yes, it is safe. This command does not delete your subscription or your account; it only removes the local license token from your hard drive so that a new one can be applied.
Why is my CMD window closing immediately after I run a command?
This usually happens if you are running a script file rather than typing directly into the prompt. Open the Command Prompt first, then type the commands one by one to see the output.
Does this work for both Mac and Windows?
No, this specific method uses VBScripts and the Windows Command Prompt, which are exclusive to Windows. macOS uses different activation mechanisms handled through the App Store or the Microsoft account sign-in process.
What should I do if I don't have a product key but have a subscription?
If you have a subscription linked to an email, you generally do not need the CMD method. Simply sign in to any Office app with your email. Use CMD only if the sign-in process is failing due to license conflicts.