Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;Allows user to retrieve Quickbooks licensing information in a human-readable format
- ;Works on a live system (system with QB installed) or from an offline drive from another
- ;system, or just the qbregistration.dat file itself.
- regexp_version := "<VERSION number=.*?(\d{2}\.\d*?).*?>"
- regexp_flavor := "<FLAVOR name=.*?(\w+)\W*?>"
- regexp_installID := "<InstallID>(.+?)<\/InstallID>"
- regexp_license := "<LicenseNumber>(.+?)<\/LicenseNumber>"
- regexp := "Os)" regexp_version ".*?" regexp_flavor ".*?" regexp_installID ".*?" regexp_license
- ;Quickbooks version list
- pro := "Pro "
- bel := "Enterprise Solutions "
- superpro := "Premier "
- accountant := "Premier Accountant Edition "
- belacct := "Enterprise Accountant Edition "
- ;turn the version number (ie, 26.0) into the year (2016). Holds up for every
- ;version up until 2017, which is current at the time of writing.
- qbyear(year)
- {
- return Floor(2000 + year - 10)
- }
- ;end list
- ;Get a list of valid drive letters attached to this system
- DriveGet, drive_list, List
- ;Cycle through the drive letter list and discard drive letters that have not
- ;drive attached to them
- dl_pos := 1
- drive_list_actual := ""
- while (dl_pos < strlen(drive_list)) {
- this_letter := SubStr(drive_list, dl_pos, 1)
- DriveGet, this_capacity, Capacity, %this_letter%:\
- if (this_capacity)
- drive_list_actual := drive_list_actual . this_letter . "|"
- dl_pos++
- }
- drive_list_actual_len := StrLen(drive_list_actual)
- drive_list_actual := SubStr(drive_list_actual, 1, drive_list_actual_len-1)
- ;Create and show the GUI
- Gui, -Border +Caption -MinimizeBox -MaximizeBox -OwnDialogs -Resize +SysMenu +Theme -ToolWindow
- Gui, Add, Text, x10 y10 w460 h80, Tool to retrieve QuickBooks product information from a qbregistration.dat file. Choose a drive letter from the dropdown menu and let the program try to find the registration file`, or specify an absolute path to the file in the textbox below.
- Gui, Add, GroupBox, x10 y100 w450 h100, Select file location
- Gui, Add, Radio, x20 y130 w150 h20 checked vguichoice gGuiChangeChoice, Find file on selected drive:
- Gui, Add, Radio, x20 y170 w150 h20 gGuiChangeChoice, Specify file location:
- Gui, Add, DropDownList, x180 y130 w90 h20 R5 vdrive_letter, %drive_list_actual%
- Gui, Add, Edit, x180 y170 w150 h20 -Multi vfilePath Disabled,
- Gui, Add, Button, x340 y170 w100 h20 vbrowseButton gBrowse Disabled, Browse
- Gui, Add, Button, x360 y210 w100 h30 gRetrieve, OK
- Gui, Show, Center w475 h246, QB Registration Puller
- return
- Browse:
- FileSelectFile, filePathSelect, 3,,Select Quickbooks Registration File, QB Registration Files (*.dat)
- if (filePathSelect)
- GuiControl,,filePath, %filePathSelect%
- return
- ;Enables/disables other controls based on which radio button is selected
- GuiChangeChoice:
- Gui, Submit, NoHide
- if (guichoice == 1) {
- GuiControl, Disable, filePath
- GuiControl, Disable, browseButton
- GuiControl, Enable, drive_letter
- }
- else {
- GuiControl, Enable, filePath
- GuiControl, Enable, browseButton
- GuiControl, Disable, drive_letter
- }
- return
- Retrieve:
- Gui, Submit, NoHide
- if (guichoice == 1) {
- path := drive_letter . ":\ProgramData\COMMON FILES\INTUIT\QUICKBOOKS\qbregistration.dat"
- }
- else {
- path := filePathSelect
- }
- FileRead, qbreg, %path%
- qbreg := StrReplace(qbreg, "`r`n")
- qbreg := StrReplace(qbreg, "`n")
- startpos := 1
- iter := 1
- while (startpos < strlen(qbreg) and startpos) {
- RegExMatch(qbreg, regexp, outvar, startpos)
- out_version%iter% := outvar.Value(1)
- out_flavor%iter% := outvar.Value(2)
- out_installID%iter% := outvar.Value(3)
- out_license%iter% := outvar.Value(4)
- startpos := outvar.Pos(4) + outvar.Len(4)
- iter++
- }
- if (!out_version1 or !out_flavor1 or !out_installID1 or !out_license1) {
- msgbox, 48, Error pulling license information, Could not find license information at %path%`n`nHere's what we found:`n======`n%qbreg%`n======`n%out_flavor1% %out_version1% %out_installID1% %out_license1%`n======
- return
- }
- iter := 1
- while true {
- the_flavor := out_flavor%iter%
- the_year := qbyear(out_version%iter%)
- the_full_version = %the_flavor%%the_year%
- str := str "======`nVersion: " the_full_version "`nLicense: " out_license%iter% "`nInstallation ID: " out_installID%iter% "`n======`n"
- iter := iter + 1
- if !out_installID%iter%
- break
- }
- msgbox,,Quickbooks License Information, Reading from %path%`n%str%
- str := ""
- return
- GuiClose:
- GuiEscape:
- ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement