
How to use the command 'ospp.vbs' (with examples)
- Windows
- December 17, 2024
ospp.vbs is a powerful script command utilized for managing volume licensed versions of Microsoft Office. It is essential for installing, activating, and managing Office product keys on a large scale, often used in corporate environments where Microsoft Office is rolled out across many devices. This command allows administrators to replace existing keys, set KMS (Key Management Service) hosts and ports, activate product keys, and more. However, given its potency, it should be used with caution as it can modify or remove existing product activations. Below we explore various use cases for this command.
Use case 1: Install a Product Key
Code:
cscript ospp.vbs /inpkey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
Motivation:
The primary reason for using this command is to install a new product key on a system. Organizations may switch product keys to reflect licensing changes, or during migrations to newer versions of Microsoft Office. This command facilitates such changes by replacing the existing product key with a new one, ensuring that the Office suite functions under the correct licensing terms.
Explanation:
cscript: A command that runs scripts via the Windows Script Host.ospp.vbs: The script file responsible for managing Office product licenses./inpkey: A flag indicating the installation of a new product key.XXXXX-XXXXX-XXXXX-XXXXX-XXXXX: Representation of the new 25-character product key to be installed.
Example Output:
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.
---Processing--------------------------
---------------------------------------
Product key successfully installed.
---------------------------------------
Use case 2: Uninstall an Installed Product Key
Code:
cscript ospp.vbs /unpkey:XXXXX
Motivation:
Uninstalling a product key is often necessary when a device is being decommissioned or repurposed, ensuring that the specific license can be reassigned or retired. This command is also useful when the wrong product key is applied, necessitating its removal before the correct key can be installed.
Explanation:
cscript: Executes the scripting process.ospp.vbs: The targeted script for Office licensing management./unpkey: This flag signifies the command’s objective to uninstall a product key.XXXXX: The last five digits of the product key to be uninstalled, identifying the key that needs removal.
Example Output:
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.
---Processing--------------------------
---------------------------------------
Uninstalled product key ending in XXXXX successfully.
---------------------------------------
Use case 3: Set a KMS Host Name
Code:
cscript ospp.vbs /sethst:hostname
Motivation:
Setting a KMS host is critical in environments using Key Management Service for activation. This command informs the Office suite of the network location where it can manage product activations internally, reducing dependency on external activation services and aligning with enterprise IT policies.
Explanation:
cscript: Initiates the script execution.ospp.vbs: The script dealing with Office licensing./sethst: The operation flag to set a KMS host.hostname: Represents the network name or IP address of the KMS server.
Example Output:
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.
---Processing--------------------------
---------------------------------------
Successfully set the KMS host to hostname.
---------------------------------------
Use case 4: Set a KMS Port
Code:
cscript ospp.vbs /setprt:1688
Motivation:
In scenarios where network configurations have designated specific ports for KEy Management Service operations, this command adjusts the port settings for Office licensing. By specifying the correct port, you ensure that Office can communicate with the KMS server without firewall or network conflicts.
Explanation:
cscript: Triggers the script’s execution.ospp.vbs: Indicates the script responsible for Office product licensing./setprt: The command option used to set a new KMS port.1688: The default port used by KMS—can be adjusted to meet organizational requirements.
Example Output:
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.
---Processing--------------------------
---------------------------------------
Successfully set the KMS port to 1688.
---------------------------------------
Use case 5: Activate Installed Office Product Keys
Code:
cscript ospp.vbs /act
Motivation:
Activating product keys is a crucial step following installation to ensure that all Office functionalities are unlocked and legally compliant. This command connects to the designated activation service to verify and activate the installed product with little or no user intervention.
Explanation:
cscript: Runs the Windows script host to process the scripting command.ospp.vbs: The script used for managing Office licenses./act: Operation flag that initiates the activation process of installed product keys.
Example Output:
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.
---Processing--------------------------
---------------------------------------
Product activation successful.
---------------------------------------
Use case 6: Display License Information for Installed Product Keys
Code:
cscript ospp.vbs /dstatus
Motivation:
Knowing the status of installed product keys is imperative for maintenance and management. This command provides detailed information on active licenses within the system. It assists IT administrators in auditing license compliance and detecting possible activation or licensing issues.
Explanation:
cscript: Initiates the execution of the script.ospp.vbs: The script that engages with Office’s licensing system./dstatus: Command option to display the status of installed product/license keys.
Example Output:
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.
---Processing--------------------------
---------------------------------------
License status: Licensed
Description: Office 16, Product activated
Expiration: Not Set
---------------------------------------
Conclusion:
The ‘ospp.vbs’ command is an essential tool for IT administrators managing volume licensed versions of Microsoft Office. Through various functionalities such as installing and uninstalling product keys, setting up KMS configurations, and displaying license statuses, the command aids in maintaining compliance, ensuring seamless activation, and supporting efficient license management within organizations.

