none
VB code for Office Validation RRS feed

  • Question

  • Hi Scripting Guy!

    I need some help with this:

    "Create a simple .vbs file which validates if the current office version if activated. As a function, the output result as a message box will be YES or NO."

    Thanks a lot!

    Thursday, December 12, 2013 5:22 PM

Answers

  • Depends on what version of Office you're using.  The most recent versions use the same activation scheme as Windows (KMS or MAK activation for volume licensing, etc).  You can view the status of Office activation by running the "ospp.vbs" script with the /dstatus switch.  If you're curious, you can also open up that VBScript file in Notepad to see how it works via WMI under the hood (classes like OfficeSoftwareProtectionProduct in the root/cimv2 namespace).

    Edit:  OSPP.vbs is in the same directory as your Office executables, for example:  C:\Program Files\Microsoft Office\Office14\

    Thursday, December 12, 2013 5:35 PM

All replies

  • Is it a test or homework question? What does your script look like so far?

    Bill

    Thursday, December 12, 2013 5:28 PM
    Moderator
  • Hi,

    Where's your code? We'll need to see it (and your errors) before we can help.

    EDIT: Bill has a good point, this does sound like homework....


    Don't retire TechNet! - (Don't give up yet - 12,420+ strong and growing)


    Thursday, December 12, 2013 5:29 PM
  • Hi Bill

    I'm currently developing some vbs code for a software in my company, and I'm stucked in this part. I need to check if any user has the office version activated, before executing some functions, involving macros in excel and word. Can you help me with this?

    Thanks.

    Thursday, December 12, 2013 5:33 PM
  • What does your script look like so far?

    We can help if you have a specific question, but this isn't a script on demand forum.

    Bill

    Thursday, December 12, 2013 5:34 PM
    Moderator
  • Depends on what version of Office you're using.  The most recent versions use the same activation scheme as Windows (KMS or MAK activation for volume licensing, etc).  You can view the status of Office activation by running the "ospp.vbs" script with the /dstatus switch.  If you're curious, you can also open up that VBScript file in Notepad to see how it works via WMI under the hood (classes like OfficeSoftwareProtectionProduct in the root/cimv2 namespace).

    Edit:  OSPP.vbs is in the same directory as your Office executables, for example:  C:\Program Files\Microsoft Office\Office14\

    Thursday, December 12, 2013 5:35 PM
  • Well, I found the OSPP.VBS file in the Office directory, but I would like to know if there is a SIMPLIFIED version of that script which may help me with what I need. Is that possible?

    Thursday, December 12, 2013 5:44 PM
  • Thanks David, I've checked that. But I'm not a programmer, and I'm looking for established code for this. And I have a limit of 4k characters for this specific function. Is that possible?
    Thursday, December 12, 2013 5:52 PM
  • Thanks David, I've checked that. But I'm not a programmer, and I'm looking for established code for this. And I have a limit of 4k characters for this specific function. Is that possible?

    Huh?  What exactly are you doing, where you have a character limit on a function?
    Thursday, December 12, 2013 5:59 PM
  • The software that allows including vbscript code as functions has that limit. I can link functions, if necessary. Have you ever heard of ERP software named IFS? I'm developing some macros on it, but I'm stucked on the part where I need to validate the Office 2010 before executing specific functions.
    Thursday, December 12, 2013 7:10 PM
  • I see.  Well, it's pretty straightforward WMI code; you can find examples of sample VBScript code to query WMI classes all over the older Scripting Guy blog posts and TechNet (though these days, it's all about PowerShell.)

    You'll want to query the OfficeSoftwareProtectionProduct class for objects where "ProductKeyID" isn't blank / null, and check the LicenseStatus value of those objects.  A LicenseStatus of 1 means it's activated.  Depending on what products you have installed, there may be multiple results (one for Project, one for Visio, that kind of thing.)

    Thursday, December 12, 2013 7:16 PM
  • Thanks a lot! That was helpful :)
    Friday, December 13, 2013 2:20 PM