Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- title Download an website using CMD.
- del /Q "%~dp0DScript.vbs"
- cls
- echo Generating script..
- echo 'script by Salmon Trout: https://www.computerhope.com/forum/index.php?topic=110781.0 >> "%~dp0DScript.vbs"
- echo.>> "%~dp0DScript.vbs"
- echo myURL = wscript.arguments(0) >> "%~dp0DScript.vbs"
- echo myPath = wscript.arguments(1) >> "%~dp0DScript.vbs"
- echo Dim i, objFile, objFSO, objHTTP, strFile, strMsg >> "%~dp0DScript.vbs"
- echo Const ForReading = 1, ForWriting = 2, ForAppending = 8 >> "%~dp0DScript.vbs"
- echo Set objFSO = CreateObject( "Scripting.FileSystemObject" ) >> "%~dp0DScript.vbs"
- echo If objFSO.FolderExists( myPath ) Then >> "%~dp0DScript.vbs"
- echo strFile = objFSO.BuildPath( myPath, Mid( myURL, InStrRev( myURL, "/" ) + 1 ) ) >> "%~dp0DScript.vbs"
- echo ElseIf objFSO.FolderExists( Left( myPath, InStrRev( myPath, "\" ) - 1 ) ) Then >> "%~dp0DScript.vbs"
- echo strFile = myPath >> "%~dp0DScript.vbs"
- echo Else >> "%~dp0DScript.vbs"
- echo WScript.Echo "ERROR: Target folder not found." >> "%~dp0DScript.vbs"
- echo wscript.Quit >> "%~dp0DScript.vbs"
- echo End If >> "%~dp0DScript.vbs"
- echo Set objFile = objFSO.OpenTextFile( strFile, ForWriting, True ) >> "%~dp0DScript.vbs"
- echo Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" ) >> "%~dp0DScript.vbs"
- echo.>> "%~dp0DScript.vbs"
- echo 'following line is optional >> "%~dp0DScript.vbs"
- echo wscript.echo "Downloading " ^& myURL >> "%~dp0DScript.vbs"
- echo.>> "%~dp0DScript.vbs"
- echo objHTTP.Open "GET", myURL, False >> "%~dp0DScript.vbs"
- echo objHTTP.Send >> "%~dp0DScript.vbs"
- echo For i = 1 To LenB( objHTTP.ResponseBody ) >> "%~dp0DScript.vbs"
- echo objFile.Write Chr( AscB( MidB( objHTTP.ResponseBody, i, 1 ) ) ) >> "%~dp0DScript.vbs"
- echo Next >> "%~dp0DScript.vbs"
- echo objFile.Close( ) >> "%~dp0DScript.vbs"
- echo.>> "%~dp0DScript.vbs"
- echo 'following line is optional >> "%~dp0DScript.vbs"
- echo wscript.echo "Download complete" >> "%~dp0DScript.vbs"
- echo Generation complete!
- echo.
- :: Input website bellow followed with output location.
- cscript //nologo "%~dp0DScript.vbs" "http://www.robgendlerastropics.com/primer.html" "C:\Users\%username%\Downloads"
- echo.
- del /Q "%~dp0DScript.vbs"
- echo Job finished!
- echo.
- pause.
Add Comment
Please, Sign In to add comment