0

Hi so im building a script which downloads a .exe file via urllib. Sadly,the downloaded file, when executed, shows an error prompt by windows, the file would be damaged or corrupted and cannot be executed.

My script:

url = 'https://anonfiles.com/51l035B5x5/npp.8.1.9.3.Installer.x64_exe'

f = urllib.request.urlopen(url)
file = f.read()
f.close()
f2 = open('npp.exe', 'wb')
f2.write(file)
f2.close()

how to proceed so the file is working when downloaded?

  • Might be an issue with the file itself but try out this recommendation https://stackoverflow.com/a/22776/5562041 – E_K Jan 15 '22 at 15:57

1 Answers1

0

Try downloading it like this instead:

import urllib.request
urllib.request.urlretrieve("https://anonfiles.com/51l035B5x5/npp.8.1.9.3.Installer.x64_exe", "npp.exe")

If that doesn't work, the executable might be broken itself.

Robiot
  • 112
  • 1
  • 2
  • 9
  • sadly still "the file or directory is damaged and unreadable". tried to download from link and execute, but the file downloaded manually worked all fine. – janamyers220 Jan 15 '22 at 16:05
  • Can you try downloading some other executable from another site and check if that works? – Robiot Jan 15 '22 at 16:07
  • i tried with bashupload.com and it worked.i think the problem is anonfiles is too spammy and opens new tabs instead of downloading often – janamyers220 Jan 15 '22 at 16:15