Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.07 KB | None | 0 0
  1. @echo off
  2.  
  3. :main
  4. echo Updating file...
  5. [PROGRESS BAR HERE]
  6.  
  7. @echo off
  8. setlocal EnableDelayedExpansion
  9.  
  10. rem Count the number of files in this dir (just as an example)
  11. set n=0
  12. for %%f in (*.*) do set /A n+=1
  13.  
  14. rem Fill "bar" variable with 70 characters
  15. set "bar="
  16. for /L %%i in (1,1,70) do set "bar=!bar!X"
  17.  
  18. rem Fill "space" variable with filler spaces
  19. set "space="
  20. for /L %%i in (1,1,110) do set "space=!space!_"
  21.  
  22. rem "Process" the files and show the progress bar in the title
  23. set i=0
  24. echo Processing files:
  25. for %%f in (*.*) do (
  26. set /A i+=1, percent=i*100/n, barLen=70*percent/100
  27. for %%a in (!barLen!) do title !percent!%% !bar:~0,%%a!%space%
  28. echo !i!- %%f
  29. ping -n 1 localhost > NUL
  30. )
  31.  
  32. title MS-DOS
  33.  
  34. @echo off
  35.  
  36. setlocal enableextensions disabledelayedexpansion
  37.  
  38. for /l %%f in (0 1 100) do (
  39. call :drawProgressBar %%f "up test with a long text that will not fit on screen unless you have a lot of space"
  40. )
  41. for /l %%f in (100 -5 0) do (
  42. call :drawProgressBar %%f "going down test"
  43. )
  44. for /l %%f in (0 5 100) do (
  45. call :drawProgressBar !random! "random test"
  46. )
  47.  
  48. rem Clean all after use
  49. call :finalizeProgressBar
  50.  
  51. endlocal
  52. exit /b
  53.  
  54.  
  55. :drawProgressBar value [text]
  56. if "%~1"=="" goto :eof
  57. if not defined pb.barArea call :initProgressBar
  58. setlocal enableextensions enabledelayedexpansion
  59. set /a "pb.value=%~1 %% 101", "pb.filled=pb.value*pb.barArea/100", "pb.dotted=pb.barArea-pb.filled", "pb.pct=1000+pb.value"
  60. set "pb.pct=%pb.pct:~-3%"
  61. if "%~2"=="" ( set "pb.text=" ) else (
  62. set "pb.text=%~2%pb.back%"
  63. set "pb.text=!pb.text:~0,%pb.textArea%!"
  64. )
  65. <nul set /p "pb.prompt=[!pb.fill:~0,%pb.filled%!!pb.dots:~0,%pb.dotted%!][ %pb.pct% ] %pb.text%"
  66. type "%pb.crfile%"
  67. endlocal
  68. goto :eof
  69.  
  70. :initProgressBar [fillChar] [dotChar]
  71. if defined pb.crfile call :finalizeProgressBar
  72. setlocal enableextensions enabledelayedexpansion
  73. call :getTMPFilename pb.crfile
  74. call :getCarriageReturnFile "%pb.crfile%"
  75. if "%~1"=="" ( set "pb.fillChar=#" ) else ( set "pb.fillChar=%~1" )
  76. if "%~2"=="" ( set "pb.dotChar=." ) else ( set "pb.dotChar=%~2" )
  77. set "pb.console.columns="
  78. for /f "tokens=2 skip=4" %%f in ('mode con') do if not defined pb.console.columns set "pb.console.columns=%%f"
  79. set /a "pb.barArea=pb.console.columns/2-2"
  80. set /a "pb.textArea=pb.barArea-9"
  81. set "pb.fill="
  82. for /l %%p in (1 1 %pb.barArea%) do set "pb.fill=!pb.fill!%pb.fillChar%"
  83. set "pb.fill=!pb.fill:~0,%pb.barArea%!"
  84. set "pb.dots=!pb.fill:%pb.fillChar%=%pb.dotChar%!"
  85. set "pb.back=!pb.fill:~0,%pb.textArea%!
  86. set "pb.back=!pb.back:%pb.fillChar%= !"
  87. call :getTMPFilename pb.initFile
  88. set pb. >"%pb.initFile%"
  89. endlocal & set "pb.initFile=%pb.initFile%"
  90. (for /f "usebackq tokens=*" %%f in ("%pb.initFile%") do set "%%f") & del "%pb.initFile%" >nul & set "pb.initFile="
  91. goto :eof
  92.  
  93. :finalizeProgressBar [erase]
  94. if defined pb.crfile (
  95. if not "%~1"=="" (
  96. setlocal enabledelayedexpansion
  97. set "pb.back="
  98. for /l %%p in (1 1 %pb.console.columns%) do set "pb.back=!pb.back! "
  99. type "%pb.crfile%" & echo(!pb.back!
  100. endlocal
  101. )
  102. if exist "%pb.crfile%" del "%pb.crfile%" > nul
  103. )
  104. for /f "tokens=1 delims==" %%v in ('set pb.') do set "%%v="
  105. goto :eof
  106.  
  107. :getTMPFileName variable
  108. setlocal
  109. set "timestamp=%time::=%"
  110. set "file=%temp%%~nx0.%timestamp:,=%.%random%%random%.tmp"
  111. endlocal & set "%~1=%file%"
  112. goto :eof
  113.  
  114. :getCarriageReturnFile file
  115. for %%c in (certutil.exe) do (
  116. if not "%%~f$PATH:c"=="" (
  117. >"%~1" echo(DQ==
  118. certutil -decode -f "%~1" "%~1" >nul
  119. ) else (
  120. >"%~1._" echo Wscript.StdOut.Write^(Chr^(13^)^)
  121. cscript //nologo /E:VBScript "%~1._" > "%~1"
  122. del "%~1._" >nul 2>nul
  123. )
  124. )
  125. goto :eof
  126.  
  127. @echo off
  128. ::PROGRESS BAR
  129. set /a full = 50
  130. for /l %%a in (1,1,%full%) do (
  131. CALL:ADDSPACE)
  132. for /l %%b in (1,1,%full%) do (
  133. CALL:PROGRESS %%b
  134. )
  135. del _temp.bat
  136. exit/b
  137. :ADDSPACE
  138. set "fullBar=%fullBar%_"
  139. set "tags=%tags%#"
  140. exit/b
  141. :PROGRESS
  142. set number=%~1
  143. set /a pct=full-number
  144. (
  145. echo/echo/[%%tags:~0,%~1%%%%fullBar:~0,%pct%%%]
  146. )>_temp.bat
  147. call _temp.bat
  148. timeout 1 1>nul&cls
  149.  
  150. @echo off
  151. set load=
  152. set loadnum=0
  153. set flash=0
  154.  
  155. set installspeed=2
  156. set myapp=notepad.exe
  157.  
  158. :progressinstall
  159. set load=%load%Û
  160. cls
  161. echo.
  162. echo.
  163. echo.
  164. echo INSTALLING PLEASE WAIT
  165. echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
  166. echo %load%
  167. echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
  168. ping localhost -n %installspeed% >nul
  169. set/a loadnum=%loadnum% +1
  170. set/a flash=%flash% +1
  171. if %flash% == 9 set flash=0
  172. color 0%flash%
  173. if %loadnum% == 24 set/a loadnum=0 & set load=
  174. tasklist | find "%myapp%" > NUL
  175. If errorlevel 1 goto installcomplete
  176. goto progressinstall
  177.  
  178. :installcomplete
  179. color 07
  180. cls
  181. echo.
  182. echo.
  183. echo.
  184. echo INSTALLATION COMPLETE
  185. echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
  186. echo ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
  187. echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
  188. echo.
  189. pause
  190. cls
  191. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement