Programmatically check whether Windows 7 is activated

怎甘沉沦 提交于 2019-12-04 18:28:12

问题


Background: I am creating system images that will be loaded onto several workstations. Windows activation will occur after the images are loaded onto the workstation. These computers will not be connected to the Internet and will be activated over the phone.

Question: I would like to check programmatically if Windows 7 is activated or not, so that our software will not run if Windows 7 is not activated. Our software is written in C#.


回答1:


The Software Licensing API - SLIAPI, take at look at SLIsGenuineLocal(). (Replaces LegitCheck)




回答2:


You can run "Slmgr.vbs" on the machine and then redirect the output to check.

System.Diagnostics.Process.Start(@"cscript Slmgr.vbs > D:\\log.txt");

This will return all the information you need. Not the cleanest way to do it though.




回答3:


Not sure if it applies to Win7, but I found a post that checks XP for activation using a Win32_WindowsProductActivation class.

I'll build a test one on my machine (x64 Win7) and see if it returns activated or not, but at least gives you something to try out in the mean time.

EDIT (wish I kept reading the docs) A comment on that class page mentions that this class, on Win 7 and other versions) appears to be replaced with the Software Licensing Classes. I'll see if I can get a working result.




回答4:


You may check HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows Activation Technologies\AdminObject\Store\TotalValidations and see if it is 1. This may not be the definative way to verify activation, but you should at least be abel to see if it was validated.




回答5:


You can use this reference: https://github.com/Marko97IT/CWA In the README.md you can find the download link.



来源:https://stackoverflow.com/questions/5859073/programmatically-check-whether-windows-7-is-activated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!