locked
Script: Check activation status and activate if not RRS feed

  • Question

  • Hello,

    I know a script like this must exist out there, but I have been unable to find it through searching.

    What I'm looking for is a script that will run as a machine start up script, check the license activation status (Win 7 Ent), and if already activated do nothing, but if not activated, run the command line - slmgr.vbs /ato

    I have zero script knowledge and my feeble attempts to write a .bat using the IF condition fail miserably.

    If you have a link to a script or know what the syntax should be for a statement that asks "is Windows activated?" to create such a .bat, I would be extremely grateful.

    Thanks in advance.

    Friday, September 13, 2013 9:00 AM

Answers

  • If you have a KMS server registered with AD then the activations is automatic.

    ¯\_(ツ)_/¯

    • Marked as answer by Highspeedlane Friday, September 13, 2013 11:56 PM
    Friday, September 13, 2013 11:50 AM

All replies

  • Hello Highspeedlane,

    the WMI key "SoftwareLicensingProduct" returns you what you want.
    You could use PowerShell and call:

    Get-WmiObject SoftwareLicensingProduct | Where { $_.LicenseStatus -eq 1 }

    if no results are returned, call the slmgr.vbs.

    Cheers,
    Fred


    There's no place like 127.0.0.1

    Friday, September 13, 2013 9:37 AM
  • You cannot automatically activate Windows.  YOU can call and get an activation key and install it using slmgr but slmgr cannot do an unattended Internet Activation.


    ¯\_(ツ)_/¯

    Friday, September 13, 2013 10:13 AM
  • Fred thanks, that's a huge start for me. Will need to smarten up on PS script for this.
    Friday, September 13, 2013 10:14 AM
  • You cannot automatically activate Windows.  YOU can call and get an activation key and install it using slmgr but slmgr cannot do an unattended Internet Activation.


    ¯\_(ツ)_/¯

    Not in my environment. I have a KMS server my workstations report to for licensing and they activate with slmgr.vbs /ato. Thus I can script this command and run it, but I don't want to run it redundantly on machines that are already activated (it does not appear to hurt to run on already activated workstations, nor reduce the rearm count though).

    What I'm trying to do is automate the activation process to eliminate this additional step (run elevated CMD and run slmgr.vbs /ato) our system admin's have to do when imaging a workstation.

    Thanks again for everyone's suggestions and advice.

    Friday, September 13, 2013 10:20 AM
  • If you have a KMS server registered with AD then the activations is automatic.

    ¯\_(ツ)_/¯

    • Marked as answer by Highspeedlane Friday, September 13, 2013 11:56 PM
    Friday, September 13, 2013 11:50 AM
  • Hello,

    Let me expand and perhaps you can help me figure this out. 

    What we do now is enter the FQDN of the distant end KMS in the local group policy of each machine. Once a machine becomes a domain member, we can then execute slmgr.vbs /ato in an elevated CMD and the workstation activates the license.

    I can automate this via AD registration of the distant end KMS? Please excuse my ignorance here. 

    I have a Windows Server 2003 R2 Ent DC and all workstations are Win 7 Ent. Thanks for your efforts to help me.

    Friday, September 13, 2013 11:59 AM
  • I found a document that details that process. This is a preferred method.

    I plan to do this next time I'm in the server room and test. Thanks for your tip on this.

    Sorry this got far flung from the scripting topic, but my goal was to eliminate (by automating) a step in workstation deployment and did not know this was a viable option for that goal.

    Thanks everyone.

    Friday, September 13, 2013 11:56 PM
  • TIP: Always post a general question in the product forum for other than trivial issues.  They may know the answer or, at least, will point you in the right direction.

    Good luck.


    ¯\_(ツ)_/¯

    Saturday, September 14, 2013 12:06 AM