Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
795
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;Allows user to retrieve Quickbooks licensing information in a human-readable format
  2. ;Works on a live system (system with QB installed) or from an offline drive from another
  3. ;system, or just the qbregistration.dat file itself.
  4.  
  5. regexp_version      := "<VERSION number=.*?(\d{2}\.\d*?).*?>"
  6. regexp_flavor       := "<FLAVOR name=.*?(\w+)\W*?>"
  7. regexp_installID    := "<InstallID>(.+?)<\/InstallID>"
  8. regexp_license      := "<LicenseNumber>(.+?)<\/LicenseNumber>"
  9. regexp              := "Os)" regexp_version ".*?" regexp_flavor ".*?" regexp_installID ".*?" regexp_license
  10. ;Quickbooks version list
  11. pro         := "Pro "
  12. bel         := "Enterprise Solutions "
  13. superpro    := "Premier "
  14. accountant  := "Premier Accountant Edition "
  15. belacct     := "Enterprise Accountant Edition "
  16.  
  17. ;turn the version number (ie, 26.0) into the year (2016). Holds up for every
  18. ;version up until 2017, which is current at the time of writing.
  19. qbyear(year)
  20. {
  21.     return Floor(2000 + year - 10)
  22. }
  23. ;end list
  24.  
  25. ;Get a list of valid drive letters attached to this system
  26. DriveGet, drive_list, List
  27.  
  28. ;Cycle through the drive letter list and discard drive letters that have not
  29. ;drive attached to them
  30. dl_pos := 1
  31. drive_list_actual := ""
  32. while (dl_pos < strlen(drive_list)) {
  33.     this_letter := SubStr(drive_list, dl_pos, 1)
  34.     DriveGet, this_capacity, Capacity, %this_letter%:\
  35.     if (this_capacity)
  36.         drive_list_actual := drive_list_actual . this_letter . "|"
  37.     dl_pos++
  38. }
  39. drive_list_actual_len   := StrLen(drive_list_actual)
  40. drive_list_actual       := SubStr(drive_list_actual, 1, drive_list_actual_len-1)
  41.  
  42. ;Create and show the GUI
  43. Gui, -Border +Caption -MinimizeBox -MaximizeBox -OwnDialogs -Resize +SysMenu +Theme -ToolWindow
  44. 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.
  45. Gui, Add, GroupBox, x10 y100 w450 h100, Select file location
  46. Gui, Add, Radio, x20 y130 w150 h20 checked vguichoice gGuiChangeChoice, Find file on selected drive:
  47. Gui, Add, Radio, x20 y170 w150 h20 gGuiChangeChoice, Specify file location:
  48. Gui, Add, DropDownList, x180 y130 w90 h20 R5 vdrive_letter, %drive_list_actual%
  49. Gui, Add, Edit, x180 y170 w150 h20 -Multi vfilePath Disabled,
  50. Gui, Add, Button, x340 y170 w100 h20 vbrowseButton gBrowse Disabled, Browse
  51. Gui, Add, Button, x360 y210 w100 h30 gRetrieve, OK
  52. Gui, Show, Center w475 h246, QB Registration Puller
  53. return
  54.  
  55. Browse:
  56.     FileSelectFile, filePathSelect, 3,,Select Quickbooks Registration File, QB Registration Files (*.dat)
  57.     if (filePathSelect)
  58.         GuiControl,,filePath, %filePathSelect%
  59. return
  60.  
  61. ;Enables/disables other controls based on which radio button is selected
  62. GuiChangeChoice:
  63.     Gui, Submit, NoHide
  64.     if (guichoice == 1) {
  65.         GuiControl, Disable, filePath
  66.         GuiControl, Disable, browseButton
  67.         GuiControl, Enable, drive_letter
  68.     }
  69.     else {
  70.         GuiControl, Enable, filePath
  71.         GuiControl, Enable, browseButton
  72.         GuiControl, Disable, drive_letter
  73.     }
  74. return
  75.  
  76. Retrieve:
  77.     Gui, Submit, NoHide
  78.     if (guichoice == 1) {
  79.         path := drive_letter . ":\ProgramData\COMMON FILES\INTUIT\QUICKBOOKS\qbregistration.dat"
  80.     }
  81.     else {
  82.         path := filePathSelect
  83.     }
  84.     FileRead, qbreg, %path%
  85.     qbreg := StrReplace(qbreg, "`r`n")
  86.     qbreg := StrReplace(qbreg, "`n")
  87.     startpos := 1
  88.     iter := 1
  89.     while (startpos < strlen(qbreg) and startpos) {
  90.         RegExMatch(qbreg, regexp, outvar, startpos)
  91.         out_version%iter%   := outvar.Value(1)
  92.         out_flavor%iter%    := outvar.Value(2)
  93.         out_installID%iter% := outvar.Value(3)
  94.         out_license%iter%   := outvar.Value(4)
  95.         startpos := outvar.Pos(4) + outvar.Len(4)
  96.         iter++
  97.     }  
  98.  
  99.     if (!out_version1 or !out_flavor1 or !out_installID1 or !out_license1) {
  100.             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======
  101.             return
  102.     }
  103.            
  104.     iter := 1
  105.     while true {
  106.         the_flavor := out_flavor%iter%
  107.         the_year   := qbyear(out_version%iter%)
  108.         the_full_version = %the_flavor%%the_year%
  109.        
  110.         str := str "======`nVersion: " the_full_version "`nLicense: " out_license%iter% "`nInstallation ID: " out_installID%iter% "`n======`n"
  111.            
  112.         iter := iter + 1
  113.         if !out_installID%iter%
  114.             break
  115.     }
  116.     msgbox,,Quickbooks License Information, Reading from %path%`n%str%
  117.     str := ""
  118.    
  119.  
  120. return
  121.  
  122. GuiClose:
  123. GuiEscape:
  124. ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement