mmarcincin / HB-DRM-free-bulk-downloader

powershell script for downloading humble bundle DRM-Free files
96 stars 13 forks source link

Windows 7 Support #1

Closed Xandernardo closed 4 years ago

Xandernardo commented 5 years ago

I tried using the script on a Windows 7 Ultimate x64 machine without avail, but the script worked flawlessly on the same machine on Windows 10 x64.

As I haven't logged the error messages myself, and I'm afraid I can't retest it right now, all the feedback about the issue I can give is that PowerShell in Windows 7 may be missing some packages that Powershell has by default on Windows 10 (I think I can recall about not finding something after executing it directly on powershell, and also had this kind of problem before on Windows 7 Powershell).

Thanks in advance for your patience and support and sorry for not giving a more useful debug info, I will try as soon as I can the script on windows 7 again and paste the errors.

Edit:

After some searching, I saw a way of executing old powershells on newer OSes and managed to replicate the errors, so I ran powershell -Version 2 -File .\HB-DRM-Free_download.ps1 and got this:

Test-Path : Caracteres no válidos en la ruta de acceso.
En C:\Media\Documentos\Humblebooks\HB-DRM-Free_download.ps1: 38 Carácter: 16
+ If (!(Test-Path <<<<  $DownloadDirectory)){
    + CategoryInfo          : InvalidArgument: (\\?\C:\Media\Documentos:String) [Test-Path], Argu
   mentException
    + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.TestPathComma
   nd

New-Item : Caracteres no válidos en la ruta de acceso.
En C:\Media\Documentos\Humblebooks\HB-DRM-Free_download.ps1: 39 Carácter: 10
+     New-Item <<<<  -ItemType directory -Path $DownloadDirectory | Out-Null
    + CategoryInfo          : InvalidArgument: (\\?\C:\Media\Do...books\downloads:String) [New-It
   em], ArgumentException
    + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.NewItemComman
   d

Test-Path : Caracteres no válidos en la ruta de acceso.
En C:\Media\Documentos\Humblebooks\HB-DRM-Free_download.ps1: 42 Carácter: 16
+ If (!(Test-Path <<<<  $temp)){
    + CategoryInfo          : InvalidArgument: (\\?\C:\Media\Documentos:String) [Test-Path], Argu
   mentException
    + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.TestPathComma
   nd

New-Item : Caracteres no válidos en la ruta de acceso.
En C:\Media\Documentos\Humblebooks\HB-DRM-Free_download.ps1: 43 Carácter: 10
+     New-Item <<<<  -ItemType directory -Path $temp | Out-Null
    + CategoryInfo          : InvalidArgument: (\\?\C:\Media\Do...\downloads\temp:String) [New-It
   em], ArgumentException
    + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.NewItemComman
   d

Remove-Item : Caracteres no válidos en la ruta de acceso.
En C:\Media\Documentos\Humblebooks\HB-DRM-Free_download.ps1: 45 Carácter: 12
+ Remove-Item <<<<  "$temp\*" -Recurse
    + CategoryInfo          : InvalidArgument: (\\?\C:\Media\Documentos:String) [Remove-Item], Ar
   gumentException
    + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.RemoveItemCom
   mand

Test-Path : Caracteres no válidos en la ruta de acceso.
En C:\Media\Documentos\Humblebooks\HB-DRM-Free_download.ps1: 48 Carácter: 16
+ If (!(Test-Path <<<<  $links)){
    + CategoryInfo          : InvalidArgument: (\\?\C:\Media\Documentos:String) [Test-Path], Argu
   mentException
    + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.TestPathComma
   nd

New-Item : Caracteres no válidos en la ruta de acceso.
En C:\Media\Documentos\Humblebooks\HB-DRM-Free_download.ps1: 49 Carácter: 10
+     New-Item <<<<  -ItemType file -Path $links | Out-Null
    + CategoryInfo          : NotSpecified: (:) [New-Item], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.NewItemComma
   nd

Get-Content : Caracteres no válidos en la ruta de acceso.
En C:\Media\Documentos\Humblebooks\HB-DRM-Free_download.ps1: 71 Carácter: 29
+ $downloadCount = Get-Content <<<<  $links | Where {$_.indexOf("https://www.humblebundle.com/down
loads?key=") -eq "0"} | Measure-Object -Line | Select -ExpandProperty Lines
    + CategoryInfo          : InvalidArgument: (\\?\C:\Media\Documentos:String) [Get-Content], Ar
   gumentException
    + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.GetContentCom
   mand

Get-Content : No existe ningún objeto en la ruta de acceso especificada \\?\C:\Media\Documentos\Hu
mblebooks\links.txt, o bien se ha filtrado por el parámetro -Include o -Exclude.
En C:\Media\Documentos\Humblebooks\HB-DRM-Free_download.ps1: 71 Carácter: 29
+ $downloadCount = Get-Content <<<<  $links | Where {$_.indexOf("https://www.humblebundle.com/down
loads?key=") -eq "0"} | Measure-Object -Line | Select -ExpandProperty Lines
    + CategoryInfo          : ObjectNotFound: (System.String[]:String[]) [Get-Content], Exception
    + FullyQualifiedErrorId : ItemNotFound,Microsoft.PowerShell.Commands.GetContentCommand

Get-Content : Caracteres no válidos en la ruta de acceso.
En C:\Media\Documentos\Humblebooks\HB-DRM-Free_download.ps1: 73 Carácter: 12
+ Get-Content <<<<  $links | Foreach-Object {
    + CategoryInfo          : InvalidArgument: (\\?\C:\Media\Documentos:String) [Get-Content], Ar
   gumentException
    + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.GetContentCom
   mand

Get-Content : No existe ningún objeto en la ruta de acceso especificada \\?\C:\Media\Documentos\Hu
mblebooks\links.txt, o bien se ha filtrado por el parámetro -Include o -Exclude.
En C:\Media\Documentos\Humblebooks\HB-DRM-Free_download.ps1: 73 Carácter: 12
+ Get-Content <<<<  $links | Foreach-Object {
    + CategoryInfo          : ObjectNotFound: (System.String[]:String[]) [Get-Content], Exception
    + FullyQualifiedErrorId : ItemNotFound,Microsoft.PowerShell.Commands.GetContentCommand

pause : El término 'pause' no se reconoce como nombre de un cmdlet, función, archivo de script o p
rograma ejecutable. Compruebe si escribió correctamente el nombre o, si incluyó una ruta de acceso
, compruebe que dicha ruta es correcta e inténtelo de nuevo.
En C:\Media\Documentos\Humblebooks\HB-DRM-Free_download.ps1: 249 Carácter: 6
+ pause <<<<
    + CategoryInfo          : ObjectNotFound: (pause:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

version 3 works flawlessly, so I guess the script is safe to run in >=Win 8 OSes.

I will update the Windows Management Framework to the latest one and it should work. For compatibility, using Get-Command cmdletname returns the path of the cmdlet, and none if it isn't found in that powershell version, all the info I got was from here: StackOverflow is-there-way-to-know-cmdlet-version-in-powershell-for-backward-compatibility.

I hope this helps, and thanks in advance.

mmarcincin commented 5 years ago

Thank you for checking and the info is useful enough to know that basic commands (or at least the aliases) don't work. The Get-Content and Test-Path fails because the script uses different representation of a path (for example: \?\C:) to supports long names. If it's changed to a default one, it fails at split, getElementsByClassName, getElementsByTagName and the pause. Based on the table in the link below, Win 7 doesn't come with Powershell 3. https://docs.microsoft.com/en-us/powershell/scripting/install/installing-windows-powershell?view=powershell-6 Installing Powershell 3+ from the link above might be a solution but first check if you are not using applications not compatible with the newer powershell (it's included at each powershell version). I'll change the readme and changelog to reflect this, most likely some check in the script itself. I just have to make sure the commands for check are version compatible :). Thanks for the feedback.

About the long names: You can find more info here if you're interested: https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file It wouldn't be required for most of the bundles but it failed at this one: 'Humble Book Bundle: Cybersecurity presented by Wiley'. Combined length of bundle name + file name was too long for normal representation. If you download similar bundle, you might be surprised when you examine the folder in the Windows Explorer. The size of the bundle folder might not be the correct one but copy, cut operations work correctly.