Jump to content

How and where to upload/download a file with cmd.exe/PowerShell


Recommended Posts


I wanted to download files via CMD, and the first way I discovered was FTP. I rent a server and everything worked. The problem is that it takes kinda long to type in the credentials. After some research I found this PowerShell line: 

powershell (new-object System.Net.WebClient).DownloadFile('http://website.com/file.exe','%TEMP%\file.exe')

But I have some questions:

  1.  What is the part after %TEMP% for? Is that the destination where the files "arrives"? So if i wanted to download it to C:\, I just have to change it to C:\, right?
  2. Where can I host the file for free? I found some web server hosting sites, but the only databases I was able to find were FTP and MySQL.

Thank you for your help ;)

Edited by contrix_
Link to comment
Share on other sites

The %temp% is a windows temp folder that is read in from the systems defined path for the temp folder. You could change this to any directory.

If typing a user-name and password is too much to login to ftp, use an ftp client the stores the settings for you and don't use the command line, or, script it. However, know that ftp is a protocol that no matter what, using command line or client, will send all your data in the clear, ie: plain text passwords over the wire and can be sniffed easily. Using something like SCP or SFTP would be a better way to go and avoid plain FTP at all costs if logging into a server remotely, but the service has to setup to enable it.

If you don't care about logging into ftp, there is also wget, which you'd have to install on windows, but is already installed on most llinux systems. Works much the same way as the powershell command.

 wget http://somesite.com/file -O filename.xxx

where -O means output and filename.xxx is the file to save it to. You can add a whole path too, just put it in quotes like

"c:\user\name\desktop\soem folder on desktop\file.xxx"

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...