Download web content through CMD

14,558

Solution 1

It depends entirely on how the content is stored and accessed. CMD knows how to get things from SMB network shares (\computername\folder), but you need to run a program to access most other stuff. (eg: sqlcmd for a database)

CMD does not support downloading web content. You will need to use another program to connect to the website and download the page. Obviously a browser would work. Another option is to download wget.exe from UnxUtils. Or use another scripting language like PowerShell or Wscript.

If you have access to launch PowerShell (pre-installed on Windows 7-10), you can use the .NET library to download web resources.

PS> Invoke-Webrequest 'www.mywebsite.com/myfile.txt' -OutFile '.\myfile.txt'

This will use .NET to connect to the page and download it into the local directory. To download to another directory or filename, change the -OutFile argument.

To launch this from CMD, go into a PowerShell prompt by simply typing powershell in CMD, and running the PS commands from there. Alternatively, you can run PS commands from CMD using the powershell -c command.

powershell.exe -c "invoke-webrequest 'www.mywebsite.com/myfile.txt' -outfile .\myfile.txt"

Solution 2

You can check this question.The easiest way is with bitsadmin command:

bitsadmin /transfer myDownloadJob /download /priority normal http://downloadsrv/10mb.zip c:\10mb.zip

You can try also winhttpjs.bat:

call winhhtpjs.bat https://example.com/files/some.zip -saveTo c:\somezip.zip
Share:
14,558
Prakhar Sharma
Author by

Prakhar Sharma

Updated on June 29, 2022

Comments

  • Prakhar Sharma
    Prakhar Sharma almost 2 years

    I want some way of getting an online content on the command prompt window (Windows CMD).

    Imagine some content online stored either on a hosting service or the MySql database provided to you by that hosting service. It can be any data stored in any form. I just want to remotely view it with the help of a CMD window anywhere in the world. What command should I be using?

    To make it more clear, lets just say you have one day to prepare for your exam. Rather than preparing for it, you are making a plan to cheat.

    Now your exam is going to be conducted on a computer that has been allotted to you and you are not allowed to use a browser or download any new application on the PC. But you can use Command Prompt, so your task being a cheat is to put the answers somewhere online. You cannot install anything new.

    How will you go about if you are stuck in the above scene?

    P.S This is for educational purpose only. I have no such such exams.

  • Hagen von Eitzen
    Hagen von Eitzen about 3 years
    The certutil one gives me 'access denied' (and it is not write access to %file% that id denied)
  • Zimba
    Zimba about 3 years
    By default, only TrustedInstaller has access to -urlcache. You may change user permissions, take file ownership, or edit admin group policy, or disable Windows Defender or Antivirus monitoring. When you have access, your response will similar to **** Online **** 000000 ... 05193f CertUtil: -URLCache command completed successfully. instead of Access is denied. You may also finger to bypass Windows Defender from interfering file download via C2 servers. LoLBins can bypass UAC & WDAC.