Kovacic Posted February 8, 2013 Posted February 8, 2013 One of the simplest things I need to do, and I cant do it. All I need is a script that checks to see if Windows 7 has been activated. I looked through many of the WMI references from the website below and cant find the right one to query. http://www.activexperts.com/admin/scripts/wmi/vbscript/ I was wondering if anyone has one. Thanks in advance!! C0d3 is P0etry( ͡° ͜ʖ ͡°)
JohnOne Posted February 9, 2013 Posted February 9, 2013 one here you can port. http://www.pcreview.co.uk/forums/getting-activation-status-information-t605565.html AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
guinness Posted February 9, 2013 Posted February 9, 2013 Search Scriptomatic in the Forum and use Win32_WindowsProductActivation. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
FireFox Posted February 9, 2013 Posted February 9, 2013 (edited) Note that if you have a pirated copy the WMI samples won't work. Edit : Global $strComputer, $objWMIService, $colWPA $strComputer = "." $objWMIService = ObjGet("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") If IsObj($objWMIService) Then $colWPA = $objWMIService.ExecQuery _ ("Select * from Win32_WindowsProductActivation") If IsObj($colWPA) Then Local $blHasWPA = False For $objWPA In $colWPA $blHasWPA = True ConsoleWrite( _ "Activation Required: " & $objWPA.ActivationRequired & @CRLF & _ "Caption: " & $objWPA.Caption & @CRLF & _ "Description: " & $objWPA.Description & @CRLF & _ "IsNotificationOn: " & $objWPA.IsNotificationOn & @CRLF & _ "Product ID: " & $objWPA.ProductID & @CRLF & _ "Remaining Evaluation Period: " & $objWPA.RemainingEvaluationPeriod & @CRLF & _ "Remaining Grace Period: " & $objWPA.RemainingGracePeriod & @CRLF & _ "Server Name: " & $objWPA.ServerName & @CRLF & _ "Setting ID: " & $objWPA.SettingID & @CRLF) Next If Not $blHasWPA Then ConsoleWrite("Bad guy I gotya !" & @CRLF) EndIf EndIf EndIf Edited February 9, 2013 by FireFox
Kovacic Posted February 11, 2013 Author Posted February 11, 2013 (edited) Im not running pirated copies, at least I hope I'm not... I am writing a profiler for the company I work for, and part of it is to activate windows and office if its not already activated. I have the Office portion working, but when I ran the code above, I got "Bad guy I gotya !"I did find this though: http://msdn.microsoft.com/en-us/library/windows/desktop/aa394520(v=vs.85).aspx People are saying Win32_WindowsProductActivation class doesnt work in vista and 7 :/I found this, but I'm not 100% sure how to invoke it, looks like I have some testing to do:class SoftwareLicensingProduct{ string ID; string Name; string Description; string ApplicationID; string ProcessorURL; string MachineURL; string ProductKeyURL; string UseLicenseURL; uint32 LicenseStatus; uint32 LicenseStatusReason; uint32 GracePeriodRemaining; datetime EvaluationendDate; string OfflineInstallationId; string PartialProductKey; string ProductKeyID; string LicenseFamily; string LicenseDependsOn; boolean LicenseIsAddon; uint32 VLActivationInterval; uint32 VLRenewalInterval; string KeyManagementServiceProductKeyID; string KeyManagementServiceMachine; uint32 KeyManagementServicePort; string DiscoveredKeyManagementServiceMachineName; uint32 DiscoveredKeyManagementServiceMachinePort; uint32 IsKeyManagementServiceMachine; uint32 KeyManagementServiceCurrentCount; uint32 RequiredClientCount; uint32 KeyManagementServiceUnlicensedRequests; uint32 KeyManagementServiceLicensedRequests; uint32 KeyManagementServiceOOBGraceRequests; uint32 KeyManagementServiceOOTGraceRequests; uint32 KeyManagementServiceNonGenuineGraceRequests; uint32 KeyManagementServiceTotalRequests; uint32 KeyManagementServiceFailedRequests; uint32 KeyManagementServiceNotificationRequests; uint32 GenuineStatus; uint32 ExtendedGrace; string TokenActivationILID; uint32 TokenActivationILVID; uint32 TokenActivationGrantNumber; string TokenActivationCertificateThumbprint; string TokenActivationAdditionalInfo; datetime TrustedTime;}; Edited February 11, 2013 by Kovacic C0d3 is P0etry( ͡° ͜ʖ ͡°)
guinness Posted February 11, 2013 Posted February 11, 2013 You're not a "bad guy" read towards the end of this page. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
Kovacic Posted February 11, 2013 Author Posted February 11, 2013 (edited) I know what the product key should be, so what I might do is something like this, taking code from FireFox of course (the user, not the browser) Global $strComputer, $objWMIService, $colWPA $strComputer = "." $objWMIService = ObjGet("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") If IsObj($objWMIService) Then $colWPA = $objWMIService.ExecQuery _ ("Select * from SoftwareLicensingProduct") If IsObj($colWPA) Then Local $blHasWPA = False For $objWPA In $colWPA $blHasWPA = True MsgBox(0,"", _ "Partial Product Key: " & $objWPA.PartialProductKey) Next If Not $blHasWPA Then MsgBox(0,"","Aw crap, you bootleggin") EndIf EndIf EndIf Edited February 11, 2013 by Kovacic C0d3 is P0etry( ͡° ͜ʖ ͡°)
Moderators JLogan3o13 Posted February 11, 2013 Moderators Posted February 11, 2013 (edited) This is what I use, works well on both Windows 7 and Server 2008 boxes: $WMI = ObjGet("winmgmts:\\.\root\cimv2") $aLicenses = $WMI.ExecQuery("Select * From SoftwareLicensingProduct") For $element In $aLicenses If StringInStr($element.Description, "Windows Operating System") Then If $element.GracePeriodRemaining = 0 Then MsgBox(0, "", "Product is Activated") ExitLoop Else ;Call SLMgr.vbs with your selected options ;http://technet.microsoft.com/en-us/library/ff793433.aspx EndIf EndIf Next Edited February 11, 2013 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Chimaera Posted February 11, 2013 Posted February 11, 2013 (edited) This may help with this, i bodged this together for something i was doing a while ago expandcollapse popupGlobal $ActiveCheck, $result If @OSVersion = "WIN_2000" Or @OSVersion = "WIN_2003" Or @OSVersion = "WIN_XP" Or @OSVersion = "WIN_XPe" Then $ActiveCheck = _XPActivationCheck() Else $ActiveCheck = _ActivationStatus() EndIf Func _ActivationStatus() ; Vista + Only ~ author trancexx Local $oWMIService = ObjGet("winmgmts:\\.\root\cimv2") If IsObj($oWMIService) Then Local $oCollection = $oWMIService.ExecQuery("SELECT Description, LicenseStatus, GracePeriodRemaining FROM SoftwareLicensingProduct WHERE PartialProductKey <> null") If IsObj($oCollection) Then For $oItem In $oCollection Switch $oItem.LicenseStatus Case 0, 2 To 4, 6 $result = "Windows Is NOT Activated" Case 1 $result = "Windows Is Activated" Case 5 $result = "Possible Fixed Windows (Notification Mode)" EndSwitch ;~ Return ConsoleWrite( $result & @CRLF) Return MsgBox(0, "Activation Result", $result & @CRLF) Next EndIf EndIf EndFunc ;==>_ActivationStatus Func _XPActivationCheck() ; XP only Local $x = ObjGet("winmgmts:{impersonationLevel=impersonate}") Local $y = $x.InstancesOf("win32_WindowsProductActivation") For $Obj In $y If $Obj.ActivationRequired Then $result = 'Windows Is NOT Activated' Else $result = 'Windows Is Activated' EndIf Next ;~ Return ConsoleWrite( $result & @CRLF) Return MsgBox(0, "Activation Result", $result & @CRLF) EndFunc ;==>_XPActivationCheck I found the Possible Fixed Windows (Notification Mode) answer usefull for Hooky/Dodgy OS because its looking for a different param which the cracks exploit but don't take it as verbatim I would prob test it thoroughly as i cant remember whether i finished it completely Edited February 11, 2013 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices()
Colyn1337 Posted February 11, 2013 Posted February 11, 2013 (edited) This might be blasphemous, however this is my Powershell script for activating windows 7. It also refreshes at the higher level so the OS can see that the license has been activated without a reboot. Note, this is for after you've already programatically had the activation code entered (ours is in our base image). (Get-WmiObject -Namespace "root\cimv2" -Class SoftwareLicensingProduct | Where-Object {$_.productkeyid -ne $null}).activate() (Get-WmiObject -Namespace "root\cimv2" -Class SoftwareLicensingService).RefreshLicenseStatus() EDIT: I highly recommend WMI Tools from microsoft, it makes scraping the WMI landscape so much easier. Edited February 11, 2013 by Colyn1337
Kovacic Posted February 11, 2013 Author Posted February 11, 2013 Actually Colyn, I was planning on bringing in much more powershell to the profiler, but I have much to learn first. 95% of my information gathering is through WMI, but I am finding some resources that work on XP, don't work on 7 or vista (not like I use vista )JLogan3o13, I did try that code, but every laptop I ran it on, said that windows was activated, even if it wasnt.Chimaera, This is working for me! Thanks!!! C0d3 is P0etry( ͡° ͜ʖ ͡°)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now