Advertisement
Guest User

qbregpuller

a guest
Apr 12th, 2017
665
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=""""(.+?)"""">"
  6. regexp_flavor       := "<FLAVOR name=""""(.+?)"""">"
  7. regexp_installID    := "<InstallID>(.+?)<\/InstallID>"
  8. regexp_license      := "<LicenseNumber>(.+?)<\/LicenseNumber>"
  9.  
  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 := filePath
  83.     FileRead, qbreg, %path%    
  84.     RegExMatch(qbreg, regexp_version, out_version)
  85.     RegExmatch(qbreg, regexp_flavor, out_flavor)
  86.     RegExMatch(qbreg, regexp_installID, out_installID)
  87.     RegExMatch(qbreg, regexp_license, out_license)
  88.  
  89.     the_flavor := %out_flavor1%
  90.     the_year   := qbyear(out_version1)
  91.     the_full_version = %the_flavor%%the_year%
  92.     if (!out_version or !out_flavor or !out_installID or !out_license)
  93.         msgbox, 48, Error pulling license information, Could not find license information at %path%
  94.     else
  95.         msgbox,, QB License Info, Version: %the_full_version%`nLicense: %out_license1%`nInstallation ID: %out_installID1%
  96. return
  97.  
  98. GuiClose:
  99. GuiEscape:
  100. ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement