Advertisement
JWLLEWELYN

EasyTech.cmd

Aug 30th, 2020 (edited)
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 5.02 KB | None | 0 0
  1. @echo off
  2.  
  3. title Project EasyTech
  4.  
  5. rem Autor: JWLLEWELYN
  6. rem Description: Script manages the creation of packages for PDQ Deploy, the downloads of programs for Windows, manages the updates of the programs.
  7. rem It allows to automate the installation of offline programs.
  8.  
  9. set "params=%*"
  10. cd /d "%~dp0" && ( if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" ) && fsutil dirty query %systemdrive% 1>nul 2>nul || (  echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/k cd ""%~sdp0"" && %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs" && "%temp%\getadmin.vbs" && exit /B )
  11.  
  12. rem ######################### General adjustments #################################
  13. set "InternetTest=www.google.com"
  14. set "DNSTest=8.8.8.8"
  15. rem ###############################################################################
  16.  
  17.  
  18.  
  19. rem ########################### Directory mapping #################################
  20. set "DirectoryDownloads=%~dp0\Downloads"
  21. set "DirectoryBinary=%~dp0\bin"
  22. set "DirectoryCatalog=%~dp0\Catalog"
  23. set "DirectoryPackages=%~dp0\Packages"
  24. set "DirectoryModules=%~dp0\Modules"
  25. rem ###############################################################################
  26.  
  27.  
  28. rem ##################### Set Plugins Architecture ################################
  29. if /I "%PROCESSOR_ARCHITECTURE%" EQU "AMD64" (goto plugins64) else (goto plugins32)
  30.  
  31. :plugins32
  32. set "wget=%DirectoryBinary%\wget-win32\wget.exe"
  33. goto Requirements
  34.  
  35. :plugins64
  36. set "wget=%DirectoryBinary%\wget-win64\wget.exe"
  37. goto Requirements
  38. rem ###############################################################################
  39.  
  40.  
  41. rem ####################### Requirements assignment ###############################
  42. :Requirements
  43. set "wgetUrl64=https://eternallybored.org/misc/wget/releases/wget-1.20.3-win64.zip"
  44. set "wgetUrl32=https://eternallybored.org/misc/wget/releases/wget-1.20.3-win32.zip"
  45. set "wgetFile64=wget-1.20.3-win64.zip"
  46. set "wgetFile32=wget-1.20.3-win32.zip"
  47. goto CheckOS
  48. rem ###############################################################################
  49.  
  50.  
  51. rem ############################### Check OS ######################################
  52. :CheckOS
  53. setlocal
  54. for /f "tokens=2 delims=[]" %%i in ('ver') do set VERSION=%%i
  55. for /f "tokens=2-3 delims=. " %%i in ("%VERSION%") do set VERSION=%%i.%%j
  56. if %VERSION% == 10.0 (
  57.     goto CheckConnection    
  58. )else (
  59.     goto OSmsg
  60. )
  61. rem ###############################################################################
  62.  
  63.  
  64. rem ########################### Check Connection ##################################
  65. :CheckConnection
  66. endlocal
  67. ping -n 1 %InternetTest%|find "bytes=" >nul
  68. IF NOT ERRORLEVEL 1 goto CheckPlugins
  69. IF     ERRORLEVEL 1 goto CheckConnection2
  70.  
  71. :CheckConnection2
  72. ping -n 3 %InternetTest%|find "bytes=" >nul
  73. IF NOT ERRORLEVEL 1 goto CheckPlugins
  74. IF     ERRORLEVEL 1 goto CheckConnection3
  75.  
  76. :CheckConnection3
  77. ping -n 1 %DNSTest%|find "bytes=" >nul
  78. IF NOT ERRORLEVEL 1 goto CheckPlugins
  79. IF     ERRORLEVEL 1 goto NoConnectionMsg
  80. rem ###############################################################################
  81.  
  82.  
  83.  
  84. rem ########################### Check Plugins #####################################
  85. :CheckPlugins
  86. if exist %wget% (
  87.     goto CatalogDownload
  88.     ) else (
  89.         goto RequirementsDownload
  90. )
  91. rem ###############################################################################
  92.  
  93.  
  94.  
  95.  
  96. rem ######################### Requirements Download ###############################
  97. :RequirementsDownload
  98. cls
  99. echo Requirements Download...
  100. echo 0%
  101. mkdir "%DirectoryDownloads%" nul
  102. mkdir "%DirectoryBinary%" >nul
  103. powershell Invoke-WebRequest -Uri "%wgetUrl64%" -OutFile "%~dp0\%DirectoryDownloads%\%wgetFile64%"
  104. powershell Expand-Archive -Path "%DirectoryDownloads%\%wgetFile64%" -DestinationPath "%DirectoryBinary%\wget-win64"
  105. echo 50%
  106. powershell Invoke-WebRequest -Uri "%wgetUrl32%" -OutFile "%DirectoryDownloads%\%wgetFile32%"
  107. echo 75%
  108. powershell Expand-Archive -Path "%DirectoryDownloads%\%wgetFile32%" -DestinationPath "%DirectoryBinary%\wget-win32"
  109. echo 100%
  110. rem ###############################################################################
  111.  
  112. :CatalogDownload
  113. echo We are under construction...
  114. pause >nul
  115. exit
  116.  
  117. rem ############################# Requirement Messages ############################
  118. :OSmsg
  119. cls
  120. echo ==============================================================================
  121. echo Your computer's operating system is not supported.
  122. echo Requires Microsoft Windows 10 Operating System.
  123. echo ==============================================================================
  124. endlocal
  125. echo Press any key to exit...
  126. pause>nul
  127. exit
  128.  
  129. :NoConnectionMsg
  130. cls
  131. echo ==============================================================================
  132. echo Your computer has no Internet connection.
  133. echo Please check your internet connection.
  134. echo ==============================================================================
  135. echo Press any key to exit...
  136. pause>nul
  137. exit
  138.  
  139.  
  140. rem ###############################################################################
  141.  
  142. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement