Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; DellDigitalDeliveryCheck.au3/.exe
- ; Created: 12/5/2013
- ; Purpose: Collects required system information and
- ; submits it to the Dell Digital Delivery
- ; service in order to get the products and
- ; keys that belong to this computer.
- ; Required library: WinHTTP (Tested with 1.6.3.4)
- ; http://code.google.com/p/autoit-winhttp/downloads/list
- ;
- ; NOTE: This is day-old code that I _just_ finished writing. It's not very
- ; polished, but does what I need it to do.
- #include <Date.au3>
- #include "WinHTTP.au3"
- ; Query WMI for Win32_ComputerSystemProduct and Win32_Baseboard
- $sWMIService = "winmgmts:\\" & @ComputerName & "\root\CIMV2"
- $objWMIService = ObjGet($sWMIService)
- If IsObj($objWMIService) Then
- $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_BaseBoard")
- If IsObj($colItems) Then
- For $oItem In $colItems
- $sBBProduct = $oItem.Product
- $sBBSerialNum = $oItem.SerialNumber
- Next
- EndIf
- $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct")
- If IsObj($colItems) Then
- For $oItem IN $colItems
- $sCSPSerialNum = $oItem.IdentifyingNumber
- $sCSPModel = $oItem.Name
- $sCSPVendor = $oItem.Vendor
- $sCSPVersion = $oItem.Version
- Next
- EndIf
- $objWmiService = ""
- $colItems = ""
- $oItem = ""
- Else
- MsgBox(0, "DDD Check", "Failed to query WMI.")
- exit
- EndIf
- ; Ask which serial number to use
- $sInpSerialNumber = InputBox("DDD Check", "Enter serial number to check against", $sCSPSerialNum)
- if $sInpSerialNumber <> "" Then
- ; Just use our local serial number if the input is bad
- $sCSPSerialNum = $sInpSerialNumber
- EndIf
- ; Put together and submit our request
- $tDateTime = _Date_Time_GetSystemTime()
- $sDateTime = _Date_Time_SystemTimeToDateTimeStr($tDateTime, 1)
- ; A note on this: The commented-out line will format the header the same way that the official utility does (save for the date - The official utility uses 12 hour time with a space and then 'AM or 'PM' - This code uses 24 hour time because I was lazy and it works fine regardless.)
- ; I've found that their system doesn't really care much about this, just so long as it's there.
- ;$sSTPLine = $sDateTime & "|" & "DELL1" & "|" & $sCSPSerialNum & "|" & $sCSPVendor & "|" & $sCSPModel & "|" & $sBBSerialNum & "|" & $sBBProduct
- $sSTPLine = $sDateTime & "|DELL1|" & $sCSPSerialNum & "|DELL INC.|COMPUTER MODEL|/" & $sCSPSerialNum & "/CN000000000000/|0X010C"
- $sHeaders = "Content-Type: application/xml; charset=utf-8" & @CRLF
- $sHeaders &= "X-Dell-STP: " & $sSTPLine & @CRLF
- $sHeaders &= "X-Dell-CirrusClientVersion: 2.8.1000.0" & @CRLF
- ; This 'Autorization' header is just the username and password (see below) encoded using Base64.
- $sHeaders &= "Authorization: Basic U2VydmljZUNpcnJ1czpDaXJydXNAZGVsbA==" & @CRLF
- $sUserName = "ServiceCirrus"
- $sPassword = "Cirrus@dell"
- $sDomain = "cloud.dell.com"
- $sPage = "DEEServices/DEE.svc/v1/GetEntitlements?AId=" & $sCSPSerialNum
- ; Initialize and get session handle
- $hOpen = _WinHttpOpen()
- ; Get connection handle
- $hConnect = _WinHttpConnect($hOpen, $sDomain)
- ; Make a request
- $hRequest = _WinHttpOpenRequest($hConnect, "GET", $sPage, -1, -1, -1, $WINHTTP_FLAG_SECURE)
- ; Send it. Specify additional data to send too.
- _WinHttpSendRequest($hRequest, $sHeaders)
- ; Wait for the response
- _WinHttpReceiveResponse($hRequest)
- ; See what's returned
- $sReturned = ""
- If _WinHttpQueryDataAvailable($hRequest) Then ; if there is data
- Do
- $sReturned &= _WinHttpReadData($hRequest)
- Until @error
- EndIf
- ; Close handles
- _WinHttpCloseHandle($hRequest)
- _WinHttpCloseHandle($hConnect)
- _WinHttpCloseHandle($hOpen)
- ; See what's returned
- $bFoundAcrobat = FALSE
- $aEntitlements = XMLParseSimple($sReturned, "EntitlementDTO")
- if @error Then
- Dim $aEntitlements[1]
- EndIf
- For $sEntitlement in $aEntitlements
- $sEntitlementName = XMLParseSimple($sEntitlement, "Name", '', '', 0)
- if StringinStr($sEntitlementName, "Adobe Acrobat XI") > 0 Then
- $sProductKey = XMLParseSimple($sEntitlement, "Key", '', '', 0)
- ClipPut($sProductKey)
- MsgBox(0, "DDD Check", $sProductKey & @CRLF & @CRLF & "Key is on clipboard")
- $bFoundAcrobat = TRUE
- EndIf
- Next
- if not $bFoundAcrobat Then
- MsgBox(0, "DDD Check", "Did not find Adobe Acrobat XI in returned XML.")
- ClipPut($sReturned)
- MsgBox(0, "DDD Check - Raw Return", $sReturned)
- EndIf
- ; Function Name: XMLParseSimple
- ; Function Description: function to get the content of a xml-tag
- ; Function Author: ChristophX86
- Func XMLParseSimple($XML, $Tag, $Attribute='', $Parent='', $Flag=1)
- Local $Pattern = '<' & $Tag & '(?:.+?)' & $Attribute & '="(.*?)"(?:.*?)>'
- If ($Attribute = '') Then
- $Pattern = '<' & $Tag & '(?:.*?)>(.*?)</' & $Tag & '>'
- EndIf
- If ($Parent <> '') Then
- $Pattern = '<' & $Parent & '(?:.*?)>(?:.*?)' & $Pattern & '(?:.*?)</' & $Parent & '>'
- EndIf
- If ($Flag = -1) Then ; return boolean
- Return StringRegExp($XML, '(?s)' & $Pattern, 0)
- EndIf
- Local $SRE = StringRegExp($XML, '(?s)' & $Pattern, 3)
- If @error Then
- SetError(1)
- Return ''
- Else
- Switch $Flag
- Case 0 ; return only first match
- If (UBound($SRE, 1) >= 1) Then
- Return $SRE[0]
- Else
- SetError(10)
- Return $SRE
- EndIf
- Case 1 ; return the complete array
- Return $SRE
- Case Else
- SetError(2)
- Return $SRE
- EndSwitch
- EndIf
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement