Guest User

Untitled

a guest
Dec 28th, 2016
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. @echo off
  2. setlocal EnableDelayedExpansion
  3. if %1==colortext (
  4. set l=1
  5. if NOT EXIST C:\Windows\System32\findstr.exe (
  6. echo BAPI does not support colortext for computers that have OS's older than Win 2000/ME.
  7. )
  8. if EXIST C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe (
  9. goto COLORTEXT_POWERSH
  10. set l=0
  11. goto :eof
  12. )
  13. if EXIST C:\Windows\System32\findstr.exe (
  14. if l==1 (
  15. goto :COLORTEXT_STANDARD
  16. goto :eof
  17. )
  18. )
  19. )
  20.  
  21. REM The BAPI.
  22.  
  23.  
  24.  
  25.  
  26.  
  27. :COLORTEXT_STANDARD
  28. for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
  29. set "DEL=%%a"
  30. )
  31. @echo off
  32. <nul set /p ".=%DEL%" > "%~3"
  33. findstr /v /a:%2 /R "^$" "%~3" nul
  34. del "%~3" > nul 2>&1
  35. goto :eof
  36. ENDLOCAL
  37.  
  38.  
  39. :COLORTEXT_POWERSH
  40. set "text=%2"
  41. set "color=%3"
  42. set bc=%color:~0,1%
  43. set fc=%color:~-1%
  44. if %bc%==0 (
  45. set bcn=Black
  46. call :dofcn
  47. )
  48. if %bc%==1 (
  49. set bcn=DarkBlue
  50. call :dofcn
  51. )
  52. if %bc%==2 (
  53. set bcn=DarkGreen
  54. call :dofcn
  55. )
  56. if %bc%==3 (
  57. set bcn=DarkCyan
  58. call :dofcn
  59. )
  60. if %bc%==4 (
  61. set bcn=DarkRed
  62. call :dofcn
  63. )
  64. if %bc%==5 (
  65. set bcn=DarkMagenta
  66. call :dofcn
  67. )
  68. if %bc%==6 (
  69. set bcn=DarkYellow
  70. call :dofcn
  71. )
  72. if %bc%==7 (
  73. set bcn=Gray
  74. call :dofcn
  75. )
  76. if %bc%==8 (
  77. set bcn=DarkGray
  78. call :dofcn
  79. )
  80. if %bc%==9 (
  81. set bcn=Blue
  82. call :dofcn
  83. )
  84. if %bc%==A (
  85. set bcn=Green
  86. call :dofcn
  87. )
  88. if %bc%==B (
  89. set bcn=Cyan
  90. call :dofcn
  91. )
  92. if %bc%==C (
  93. set bcn=Red
  94. call :dofcn
  95. )
  96. if %bc%==D (
  97. set bcn=Magenta
  98. call :dofcn
  99. )
  100. if %bc%==E (
  101. set bcn=Yellow
  102. call :dofcn
  103. )
  104. if %bc%==F (
  105. set bcn=White
  106. call :dofcn
  107. )
  108.  
  109. :dofcn
  110. if %fc%==0 (
  111. set fcn=Black
  112. call :dopws
  113. )
  114. if %fc%==1 (
  115. set fcn=DarkBlue
  116. call :dopws
  117. )
  118. if %fc%==2 (
  119. set fcn=DarkGreen
  120. call :dopws
  121. )
  122. if %fc%==3 (
  123. set fcn=DarkCyan
  124. call :dopws
  125. )
  126. if %fc%==4 (
  127. set fcn=DarkRed
  128. call :dopws
  129. )
  130. if %fc%==5 (
  131. set fcn=DarkMagenta
  132. call :dopws
  133. )
  134. if %fc%==6 (
  135. set fcn=DarkYellow
  136. call :dopws
  137. )
  138. if %fc%==7 (
  139. set fcn=Gray
  140. call :dopws
  141. )
  142. if %fc%==8 (
  143. set fcn=DarkGray
  144. call :dopws
  145. )
  146. if %fc%==9 (
  147. set fcn=Blue
  148. call :dopws
  149. )
  150. if %fc%==A (
  151. set fcn=Green
  152. call :dopws
  153. )
  154. if %fc%==B (
  155. set fcn=Cyan
  156. call :dopws
  157. )
  158. if %fc%==C (
  159. set fcn=Red
  160. call :dopws
  161. )
  162. if %fc%==D (
  163. set fcn=Magenta
  164. call :dopws
  165. )
  166. if %fc%==E (
  167. set fcn=Yellow
  168. call :dopws
  169. )
  170. if %fc%==F (
  171. set fcn=White
  172. call :dopws
  173. )
  174.  
  175. :dopws
  176. set "script=write-host !text! -ForegroundColor %fcn% -BackgroundColor %bcn%"
  177. echo !script!> colortest.ps1
  178.  
  179. @echo on
  180. @powershell -executionpolicy remotesigned -file colortest.ps1
  181. @echo off
  182. del colortest.ps1
  183. set script=
  184. set bc=
  185. set bcn=
  186. set fc=
  187. set fcn=
  188. ENDLOCAL
  189. exit /b
Advertisement
Add Comment
Please, Sign In to add comment