Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 289 Vote(s) - 3.54 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Windows batch file file download from a URL

#11
This should work i did the following for a game server project. It will download the zip and extract it to what ever directory you specify.

Save as **name.bat** or **name.cmd**

@echo off
set downloadurl=http://media.steampowered.com/installer/steamcmd.zip
set downloadpath=C:\steamcmd\steamcmd.zip
set directory=C:\steamcmd\
%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe -Command "& {Import-Module BitsTransfer;Start-BitsTransfer '%downloadurl%' '%downloadpath%';$shell = new-object -com shell.application;$zip = $shell.NameSpace('%downloadpath%');foreach($item in $zip.items()){$shell.Namespace('%directory%').copyhere($item);};remove-item '%downloadpath%';}"
echo download complete and extracted to the directory.
pause

Original :

[To see links please register here]

Reply

#12
If bitsadmin isn't your cup of tea, you can use this PowerShell command:

Start-BitsTransfer -Source

[To see links please register here]

-Destination C:\somedir\package.zip
Reply

#13
Use <a href="http://www.f2ko.de/en/b2e.php">Bat To Exe Converter</a><br><br>
Create a batch file and put something like the code below into it<br>

%extd% /download

[To see links please register here]

file.zip

or

%extd% /download

[To see links please register here]

thistopic.html

and convert it to exe.
Reply

#14
This question has very good answer in [here][1]. My code is purely based on that answer with some modifications.

Save below snippet as **wget.bat** and put it in your system path (e.g. Put it in a directory and add this directory to system path.)

You can use it in your cli as follows:

`wget url/to/file [?custom_name]`

where `url_to_file` is compulsory and `custom_name` is optional

1. If name is not provided, then downloaded file will be saved by its own name from the url.
2. If the name is supplied, then the file will be saved by the new name.

The file url and saved filenames are displayed in ansi colored text. If that is causing problem for you, then check [this][2] github project.


@echo OFF
setLocal EnableDelayedExpansion
set Url=%1
set Url=!Url:http://=!
set Url=!Url:/=,!
set Url=!Url:%%20=?!
set Url=!Url: =?!

call :LOOP !Url!

set FileName=%2
if "%2"=="" set FileName=!FN!

echo.
echo.Downloading: %1 to \!FileName!

powershell.exe -Command wget %1 -OutFile !FileName!

goto :EOF
:LOOP
if "%1"=="" goto :EOF
set FN=%1
set FN=!FN:?= !
shift
goto :LOOP


*P.S. This code requires you to have PowerShell installed.*

[1]:

[To see links please register here]

[2]:

[To see links please register here]

Reply

#15
Instead of wget you can also use aria2 to download the file from a particular URL.

See the following link which will explain more about aria2:

[To see links please register here]

Reply

#16
You can setup a scheduled task using wget, use the “Run” field in scheduled task as:

C:\wget\wget.exe -q -O nul "http://www.google.com/shedule.me"
Reply

#17
Last I checked, there isn't a command line command to connect to a URL from the MS command line. Try wget for Windows:

[To see links please register here]


or URL2File:

[To see links please register here]


In Linux, you can use "wget".

Alternatively, you can try VBScript. They are like command line programs, but they are scripts interpreted by the wscript.exe scripts host. Here is an example of downloading a file using VBS:

[To see links please register here]

Reply

#18
With PowerShell 2.0 (Windows 7 preinstalled) you can use:

(New-Object Net.WebClient).DownloadFile('http://www.example.com/package.zip', 'package.zip')

Starting with PowerShell 3.0 (Windows 8 preinstalled) you can use [`Invoke-WebRequest`][1]:

Invoke-WebRequest

[To see links please register here]

-OutFile package.zip

From a batch file they are called:

powershell -Command "(New-Object Net.WebClient).DownloadFile('http://www.example.com/package.zip', 'package.zip')"
powershell -Command "Invoke-WebRequest

[To see links please register here]

-OutFile package.zip"


(PowerShell 2.0 is available for installation on XP, 3.0 for Windows 7)


[1]:

[To see links please register here]

Reply

#19
There's a utility (resides with CMD) on Windows which can be run from CMD (if you have write access):



set url=https://www.nsa.org/content/hl-images/2017/02/09/NSA.jpg
set file=file.jpg
certutil -urlcache -split -f %url% %file%
echo Done.



Built in Windows application. No need for external downloads.



Tested on Win 10
Reply

#20
Downloading files in PURE BATCH...
**Without any JScript, VBScript, Powershell, etc... Only pure Batch!**
-----

Some people are saying it's not possible of downloading files with a batch script without using any JScript or VBScript, etc... But they are definitely wrong!

Here is a simple method that seems to work pretty well for downloading files in your batch scripts. It should be working on almost any file's URL. It is even possible to use a proxy server if you need it.

For downloading files, we can use **BITSADMIN.EXE** from the Windows system. There is no need for downloading/installing anything or using any JScript or VBScript, etc. **Bitsadmin.exe** is present on most Windows versions, probably from XP to Windows 10.

Enjoy!


---

**USAGE:**

You can use the BITSADMIN command directly, like this:
`bitsadmin /transfer mydownloadjob /download /priority FOREGROUND "http://example.com/File.zip" "C:\Downloads\File.zip"`

Proxy Server:
For connecting using a proxy, use this command before downloading.
`bitsadmin /setproxysettings mydownloadjob OVERRIDE "proxy-server.com:8080"`


Click this [LINK][1] if you want more info about BITSadmin.exe

---

**TROUBLESHOOTING:**
If you get this error: "Unable to connect to BITS - 0x80070422"
Make sure the windows service "Background Intelligent Transfer Service (BITS)" is enabled and try again. (It should be enabled by default.)

---

**CUSTOM FUNCTIONS**
`Call :DOWNLOAD_FILE "URL"`
`Call :DOWNLOAD_PROXY_ON "SERVER:PORT"`
`Call :DOWNLOAD_PROXY_OFF`

I made these 3 functions for simplifying the bitsadmin commands. It's easier to use and remember. It can be particularly useful if you are using it multiple times in your scripts.

PLEASE NOTE...
Before using these functions, you will first need to copy them from CUSTOM_FUNCTIONS.CMD to the end of your script. There is also a complete example: DOWNLOAD-EXAMPLE.CMD

**:DOWNLOAD_FILE "URL"**
The main function, will download files from URL.

**:DOWNLOAD_PROXY_ON "SERVER:PORT"**
(Optional) You can use this function if you need to use a proxy server.
Calling the :DOWNLOAD_PROXY_OFF function will disable the proxy server.

**EXAMPLE:**
`CALL :DOWNLOAD_PROXY_ON "proxy-server.com:8080"`
`CALL :DOWNLOAD_FILE "http://example.com/File.zip" "C:\Downloads\File.zip"`
`CALL :DOWNLOAD_PROXY_OFF`

---


**CUSTOM_FUNCTIONS.CMD**

:DOWNLOAD_FILE
rem BITSADMIN COMMAND FOR DOWNLOADING FILES:
bitsadmin /transfer mydownloadjob /download /priority FOREGROUND %1 %2
GOTO :EOF

:DOWNLOAD_PROXY_ON
rem FUNCTION FOR USING A PROXY SERVER:
bitsadmin /setproxysettings mydownloadjob OVERRIDE %1
GOTO :EOF

:DOWNLOAD_PROXY_OFF
rem FUNCTION FOR STOP USING A PROXY SERVER:
bitsadmin /setproxysettings mydownloadjob NO_PROXY
GOTO :EOF

---

**DOWNLOAD-EXAMPLE.CMD**

@ECHO OFF
SETLOCAL

rem FOR DOWNLOADING FILES, THIS SCRIPT IS USING THE "BITSADMIN.EXE" SYSTEM FILE.
rem IT IS PRESENT ON MOST WINDOWS VERSION, PROBABLY FROM WINDOWS XP TO WINDOWS 10.


:SETUP

rem URL (5MB TEST FILE):
SET "FILE_URL=http://ipv4.download.thinkbroadband.com/5MB.zip"

rem SAVE IN CUSTOM LOCATION:
rem SET "SAVING_TO=C:\Folder\5MB.zip"

rem SAVE IN THE CURRENT DIRECTORY
SET "SAVING_TO=5MB.zip"
SET "SAVING_TO=%~dp0%SAVING_TO%"

:MAIN

ECHO.
ECHO DOWNLOAD SCRIPT EXAMPLE
ECHO.
ECHO FILE URL: "%FILE_URL%"
ECHO SAVING TO: "%SAVING_TO%"
ECHO.

rem UNCOMENT AND MODIFY THE NEXT LINE IF YOU NEED TO USE A PROXY SERVER:
rem CALL :DOWNLOAD_PROXY_ON "PROXY-SERVER.COM:8080"

rem THE MAIN DOWNLOAD COMMAND:
CALL :DOWNLOAD_FILE "%FILE_URL%" "%SAVING_TO%"

rem UNCOMMENT NEXT LINE FOR DISABLING THE PROXY (IF YOU USED IT):
rem CALL :DOWNLOAD_PROXY_OFF

:RESULT
ECHO.
IF EXIST "%SAVING_TO%" ECHO YOUR FILE HAS BEEN SUCCESSFULLY DOWNLOADED.
IF NOT EXIST "%SAVING_TO%" ECHO ERROR, YOUR FILE COULDN'T BE DOWNLOADED.
ECHO.

:EXIT_SCRIPT
PAUSE
EXIT /B




rem FUNCTIONS SECTION


:DOWNLOAD_FILE
rem BITSADMIN COMMAND FOR DOWNLOADING FILES:
bitsadmin /transfer mydownloadjob /download /priority FOREGROUND %1 %2
GOTO :EOF

:DOWNLOAD_PROXY_ON
rem FUNCTION FOR USING A PROXY SERVER:
bitsadmin /setproxysettings mydownloadjob OVERRIDE %1
GOTO :EOF

:DOWNLOAD_PROXY_OFF
rem FUNCTION FOR STOP USING A PROXY SERVER:
bitsadmin /setproxysettings mydownloadjob NO_PROXY
GOTO :EOF


[1]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through