Reputation: 33
I'm trying to find out the best way to check Windows License status using WMI query. The query should return one row indicating the license status and I want it to be as general as possible so that I can run it on many computers and different versions of operating systems.
So far have the following one:
SELECT LicenseStatus, Name, ApplicationID FROM SoftwareLicensingProduct
The problem is that it returns many rows. For example if there is Office installed it's also included in the query results and I don't know how to limit the results.
Upvotes: 0
Views: 7804
Reputation: 30248
If you do not insist upon pure wmi
query initially, try CLI command given below including output:
==>for /F "tokens=*" %G in ('where slmgr.vbs') do @cscript "%~G" /dli
Name: Windows(R), Core edition
Description: Windows(R) Operating System, OEM_COA_NSLP channel
Partial Product Key: ABCDE
License Status: Licensed
==>
Now you could (in a simple .bat
script) combine it with
==>wmic path SoftwareLicensingProduct where "PartialProductKey='ABCDE'" get LicenseStatus, Name, ApplicationID, PartialProductKey, Description /value
ApplicationID=55c92734-d682-4d71-983e-d6ec3f16059f
Description=Windows(R) Operating System, OEM_COA_NSLP channel
LicenseStatus=1
Name=Windows(R), Core edition
PartialProductKey=ABCDE
==>
or simply take a look in that slmgr.vbs
to see Microsoft solution.
Upvotes: 0