Activate Windows with CMD: Step-by-Step Guide
In this article
You cannot activate Windows with a single built-in CMD command alone. Activation requires a valid product key and an internet connection (or phone), and the correct command-line tool is slmgr.vbs, which you run from Command Prompt. The quickest working method is to open an elevated Command Prompt and run slmgr /ipk <your-25-character-key> followed by slmgr /ato. This guide walks through that process safely, explains what each step does, and covers the mistakes that cause activation to fail.
What You'll Need
- A genuine 25-character Windows product key (five groups of five characters). If Windows came preinstalled, the key is usually embedded in the firmware and you may not need to type it.
- An active internet connection for online activation.
- Administrator rights on the PC, because
slmgrchanges system licensing. - The edition of Windows that matches your key (Home, Pro, etc.). A Pro key will not activate Home.
Step-by-Step
- Open Command Prompt as administrator. Click Start, type
cmd, right-click Command Prompt and choose Run as administrator. Approve the User Account Control prompt. If you skip this, the licensing commands will fail with an access error. - Check the current activation state. Type
slmgr /xprand press Enter. A dialog box tells you whether Windows is permanently activated, in a grace period, or not activated. This gives you a baseline before changing anything. - Install your product key. Type
slmgr /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX, replacing the Xs with your real key, and press Enter. Wait for the confirmation dialog. This step only stores the key; it does not activate yet. - Activate online. Type
slmgr /atoand press Enter. Windows contacts Microsoft's activation servers. A success message means you are done; an error code means something needs fixing (see Troubleshooting). - Confirm the result. Run
slmgr /xpragain. It should now report that the machine is permanently activated. You can also check Settings > System > Activation, where the status should read Active. Menu labels can differ slightly by Windows version and region.
If you do not have a key and Windows was preinstalled, try slmgr /ato on its own first. Many OEM machines already carry a digital licence tied to the hardware, and this command simply re-contacts the server to reactivate after a hardware change or reinstall.
Common Mistakes
- Running CMD without elevation. The commands appear to run but return an access-denied or licensing error. Always use Run as administrator.
- Typing the key with spaces or dashes missing. The key must be entered exactly as five groups of five characters. Copy-paste errors and lookalike characters (0 vs O, 1 vs I) are common.
- Using a key for the wrong edition. A Windows Pro key will not activate Home. Check Settings > System > About to see your edition before buying or entering a key.
- Expecting one command to do everything.
slmgr /atoactivates but does not install a key;slmgr /ipkinstalls a key but does not activate. You need both, in that order, unless a digital licence already exists. - Using third-party "activator" tools. These are unofficial, often malicious, and violate the licence. Only use a genuine key and Microsoft's own tools.
Tips
- Run
slmgr /dlvto see detailed licence information, including the partial product key and activation expiry, which helps when diagnosing errors. - If you are reinstalling Windows on the same hardware, you often do not need to re-enter the key; the digital licence reactivates automatically once you are online. Running
slmgr /atocan speed this up. - Keep your product key somewhere safe. For retail keys, you can retrieve it later from your Microsoft account order history.
- Activate while connected to a normal home network. Corporate proxies and VPNs can block the activation servers.
- If you plan to change major hardware, activate first on the old configuration so the digital licence is established, then reactivate after the change if prompted.
Troubleshooting
If slmgr /ato returns an error, work through these checks in order, simplest first:
- Check your internet connection. Open a browser and load a page. If you are behind a proxy or VPN, disconnect and retry.
- Verify the key. Re-run
slmgr /ipkwith the key carefully retyped. A single wrong character produces an invalid-key error. - Confirm the edition matches. Settings > System > About shows your edition. If it does not match the key, you need either the correct key or to upgrade the edition through the official Microsoft Store path.
- Run the activation troubleshooter. Go to Settings > System > Activation and use the troubleshooter. It can resolve common issues such as a recently changed motherboard.
- Try phone activation. Run
slui 4from the Run dialog (Win+R). This opens the automated phone activation wizard, which is useful when online activation is blocked. - Check the service. Make sure the Software Protection service is running. Open Services from the Start menu search and look for Software Protection; if it is stopped, start it and retry
slmgr /ato. - Restart and retry. A reboot clears temporary licensing state. If activation still fails, sign out and back in, then retry once.
If none of these work, contact Microsoft Support with your error code and key receipt. Do not download unofficial activation tools, as they can compromise the PC and invalidate your licence.
Frequently Asked Questions
Can I activate Windows with Command Prompt only?
Yes, using slmgr.vbs commands from an elevated Command Prompt, provided you have a valid key and an internet connection. You still need a genuine licence; CMD is just the tool that submits it.
What is the difference between slmgr /ipk and slmgr /ato?
/ipk installs a product key into Windows. /ato attempts online activation using the installed key or an existing digital licence. Run /ipk first if you are entering a new key.
Do I need to reactivate after a Windows reinstall?
Usually not. A digital licence linked to your Microsoft account or hardware reactivates automatically once you are online. If it does not, run slmgr /ato or use the activation troubleshooter.
Why does slmgr say the key is invalid when I know it is correct?
The most common causes are a typo, a key for a different Windows edition, or a key that has already been used on the maximum number of devices. Double-check the edition and retype the key carefully.
Is it safe to use a KMS or volume activation command I found online?
No. Third-party KMS servers and unofficial activation scripts are not legitimate and can expose your PC to malware. Only use keys you purchased and Microsoft's built-in activation methods.
Can I activate Windows without internet?
Yes, through phone activation. Run slui 4 to open the wizard and follow the automated prompts. You will need to read the installation ID to the system and enter the confirmation ID it returns.