SHARE
TWEET

Auto File Downloader + Auto Run (Batch)

Imthedude025 Jan 22nd, 2018 (edited) 38 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. :::::::::::::::::::::::::::::::::::::::::::::::
  2. ::Auto File Downloader + Auto Run            ::
  3. ::Created by RU$$ [http://russdev.mooo.com/] ::
  4. :::::::::::::::::::::::::::::::::::::::::::::::
  5.  
  6. ::::::::::::::::::::::::::::::::::::::::::::::::::::::
  7. ::Config
  8. ::::::::::::::::::::::::::::::::::::::::::::::::::::::
  9.  
  10. ::File download URL (Dirrect only)
  11. SET URL=http://russdev.mooo.com/extra/foo.zip
  12.  
  13. ::File extract location (DEFAULT: Batch location)
  14. SET mypath=%~dp0
  15.  
  16. SET CreateFolder=1
  17.  
  18. SET FolderName=DownloadedFiles
  19.  
  20. ::File to auto-run (Must include extension)
  21. SET Enabled=1
  22.  
  23. SET FileName=click.exe
  24.  
  25. ::::::::::::::::::::::::::::::::::::::::::::::::::::::
  26.  
  27. ::Code start
  28. @echo off
  29.  
  30. echo Downloading file to batch dirrectory.
  31. bitsadmin /transfer mydownloadjob /download /priority normal ^ %URL% %mypath%\x.zip
  32.  
  33. echo Extracting file.
  34. powershell.exe -nologo -noprofile -command "& { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('x.zip', '%FolderName%'); }"
  35.  
  36. echo Moving the files out of folder. (If Enabled)
  37. IF %CreateFolder%==1 (goto :CON) else (goto :MOVE)
  38.  
  39. ::If move was a GO
  40. :MOVE
  41. move "%mypath%\%FolderName%\*" "%mypath%"
  42.  
  43. echo Cleaning up files.
  44. RD /S /Q "%mypath%\%FolderName%"
  45. del /F /Q "%mypath%\x.zip"
  46.  
  47. cls
  48. echo Job has finished!
  49.  
  50. ::Check if run
  51. IF %Enabled%==1 (goto :RUN) else (goto :STOP)
  52.  
  53. :RUN
  54. echo.
  55. echo Running the app.
  56. %mypath%\%FileName%
  57. pause >nul
  58. exit
  59.  
  60. :STOP
  61. pause >nul
  62. exit
  63.  
  64. ::If Move was a NO
  65. :CON
  66. echo Cleaning up files.
  67. del /F /Q "%mypath%\x.zip"
  68.  
  69. cls
  70. echo Job has finished!
  71.  
  72. ::Check if run
  73. IF %Enabled%==1 (goto :RUN2) else (goto :STOP2)
  74.  
  75. :RUN2
  76. echo.
  77. echo Running the app.
  78. %mypath%\%FolderName%\%FileName%
  79. pause >nul
  80. exit
  81.  
  82. :STOP2
  83. pause >nul
  84. exit
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top