Sign in to follow this  
Followers 0
Kovacic

Trying to make script to see if Windows 7 is activated.

11 posts in this topic

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( ͡° ͜ʖ ͡°)

Share this post


Link to post
Share on other sites



Search Scriptomatic in the Forum and use Win32_WindowsProductActivation.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by Kovacic

C0d3 is P0etry( ͡° ͜ʖ ͡°)

Share this post


Link to post
Share on other sites

You're not a "bad guy" read towards the end of this page.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#7 ·  Posted (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 by Kovacic

C0d3 is P0etry( ͡° ͜ʖ ͡°)

Share this post


Link to post
Share on other sites

#8 ·  Posted (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 by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

This may help with this, i bodged this together for something i was doing a while ago

Global $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 by Chimaera

Share this post


Link to post
Share on other sites

#10 ·  Posted (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 by Colyn1337

Share this post


Link to post
Share on other sites

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( ͡° ͜ʖ ͡°)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • Shirdish_chakravarthi
      By Shirdish_chakravarthi
      i am working on a application where if the flashing is success i get a window saying "SUCCESS" and if the flashing failed a window saying "FAILED" and i have to automatically identify pass or fail.the problem is both the windows are having the same control ID. how can i differentiate between both windows? so that i can make use of that in script for automation///
       
       
      Thanks
    • comtech80
      By comtech80
      Folks,
      I have an issue I've been trying to solve for a while, I'm trying to add static routes in DHCP via a 121 route rule in Windows 2012 R2 is a brutal manual process and wanted to automate this via AutoIT.
       
      When I use the "ControlGetText" everything displays properly in the MSG box but when I try and use "ControlSetText" or "ControlSend" the values won't display in the input box but the action comes back as successful?
      Anyone able to help me with this? I'm thinking this might be an active window issue but i'm not sure.
      Here is a part of my code.
       
      $hWnd = WinWait("[TITLE:Add a Static Route]","", 10)
      WinActivate($hWnd)
      $Status = ControlSend($hWnd, "", "[CLASS:Edit; INSTANCE:4]", "192"); Does not add 192 to the text box.
      Local $sTextEdit1 = ControlGetText($hWnd, "", "[CLASS:Edit; INSTANCE:1]")
      ConsoleWrite ( "ControlSend Status: " &  $Status & @CRLF); Returns a Value of 1
      ConsoleWrite ( "ControlGetText Value Edit1: " &  $sTextEdit1 & @CRLF);
       
      Please see attachment for more info.

    • lganta
      By lganta
      Hello!
      I created some scripts for a simple farming bot a few years ago and they rely on ControlSend.
      A year ago I quit that game and then installed Windows 10 (was using windows 7).
      Recently I installed that game and tried running them again and they seem to work (I have some messages displayed on the screen with the state of the bot ), except for the ControlSend part (which obviously is crucial).
      I started debugging the scripts so I created a basic script that makes use of Send. I tested this with Notepad in focus and works just fine and then with my game window in focus and it didn't work (it's supposed to write that text in an input box from the game).
      #include <MsgBoxConstants.au3> Sleep(3000); Send("some text"); MsgBox($MB_OK, "Notification", "Control was sent!");  
      Is there a way for the creators of the game to create some kind of security system against this? Or something happens because I updated to Windows 10?
      Is there something I'm missing?
      Thank you!
    • nacerbaaziz
      By nacerbaaziz
      Hi dear
      I have a question
      about the display language of the system
      How can I get the current display language and how can I change it by autoit
      Of course, if this is possible
      Greetings to all and hope you help me
    • breakbadsp
      By breakbadsp
      AutoIT AU3info doeas not detect all gui objects uniquely for .NET GUIs developed in C#.
      this is not working now i am using COM windows approach for this, But its very difficult.
      Please let me know if anyone has done it before.