Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- setlocal EnableDelayedExpansion
- if %1==colortext (
- set l=1
- if NOT EXIST C:\Windows\System32\findstr.exe (
- echo BAPI does not support colortext for computers that have OS's older than Win 2000/ME.
- )
- if EXIST C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe (
- goto COLORTEXT_POWERSH
- set l=0
- goto :eof
- )
- if EXIST C:\Windows\System32\findstr.exe (
- if l==1 (
- goto :COLORTEXT_STANDARD
- goto :eof
- )
- )
- )
- REM The BAPI.
- :COLORTEXT_STANDARD
- for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
- set "DEL=%%a"
- )
- @echo off
- <nul set /p ".=%DEL%" > "%~3"
- findstr /v /a:%2 /R "^$" "%~3" nul
- del "%~3" > nul 2>&1
- goto :eof
- ENDLOCAL
- :COLORTEXT_POWERSH
- set "text=%2"
- set "color=%3"
- set bc=%color:~0,1%
- set fc=%color:~-1%
- if %bc%==0 (
- set bcn=Black
- call :dofcn
- )
- if %bc%==1 (
- set bcn=DarkBlue
- call :dofcn
- )
- if %bc%==2 (
- set bcn=DarkGreen
- call :dofcn
- )
- if %bc%==3 (
- set bcn=DarkCyan
- call :dofcn
- )
- if %bc%==4 (
- set bcn=DarkRed
- call :dofcn
- )
- if %bc%==5 (
- set bcn=DarkMagenta
- call :dofcn
- )
- if %bc%==6 (
- set bcn=DarkYellow
- call :dofcn
- )
- if %bc%==7 (
- set bcn=Gray
- call :dofcn
- )
- if %bc%==8 (
- set bcn=DarkGray
- call :dofcn
- )
- if %bc%==9 (
- set bcn=Blue
- call :dofcn
- )
- if %bc%==A (
- set bcn=Green
- call :dofcn
- )
- if %bc%==B (
- set bcn=Cyan
- call :dofcn
- )
- if %bc%==C (
- set bcn=Red
- call :dofcn
- )
- if %bc%==D (
- set bcn=Magenta
- call :dofcn
- )
- if %bc%==E (
- set bcn=Yellow
- call :dofcn
- )
- if %bc%==F (
- set bcn=White
- call :dofcn
- )
- :dofcn
- if %fc%==0 (
- set fcn=Black
- call :dopws
- )
- if %fc%==1 (
- set fcn=DarkBlue
- call :dopws
- )
- if %fc%==2 (
- set fcn=DarkGreen
- call :dopws
- )
- if %fc%==3 (
- set fcn=DarkCyan
- call :dopws
- )
- if %fc%==4 (
- set fcn=DarkRed
- call :dopws
- )
- if %fc%==5 (
- set fcn=DarkMagenta
- call :dopws
- )
- if %fc%==6 (
- set fcn=DarkYellow
- call :dopws
- )
- if %fc%==7 (
- set fcn=Gray
- call :dopws
- )
- if %fc%==8 (
- set fcn=DarkGray
- call :dopws
- )
- if %fc%==9 (
- set fcn=Blue
- call :dopws
- )
- if %fc%==A (
- set fcn=Green
- call :dopws
- )
- if %fc%==B (
- set fcn=Cyan
- call :dopws
- )
- if %fc%==C (
- set fcn=Red
- call :dopws
- )
- if %fc%==D (
- set fcn=Magenta
- call :dopws
- )
- if %fc%==E (
- set fcn=Yellow
- call :dopws
- )
- if %fc%==F (
- set fcn=White
- call :dopws
- )
- :dopws
- set "script=write-host !text! -ForegroundColor %fcn% -BackgroundColor %bcn%"
- echo !script!> colortest.ps1
- @echo on
- @powershell -executionpolicy remotesigned -file colortest.ps1
- @echo off
- del colortest.ps1
- set script=
- set bc=
- set bcn=
- set fc=
- set fcn=
- ENDLOCAL
- exit /b
Advertisement
Add Comment
Please, Sign In to add comment