Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

change color batch

@echo off
REM https://pastebin.com/zjYwSqUM
Title Multi-Ping hosts Tester with colors updated on 2021 by Hackoo
call :init
set "URLS=%~dp0URLS.txt"
If Not exist "%URLS%" goto CreateDummyFile
mode con cols=70 lines=35
set "LogFile=PingResults.txt"
If exist "%LogFile%" Del "%LogFile%"
echo(
call :color 0E "      ------- Ping status of targets hosts -------" 1
echo(
(
    echo ******************************************************
    echo   PingTest executed on %Date% @ Time %Time%
    echo ******************************************************
    echo(
) > %LogFile%
Setlocal EnableDelayedExpansion
for /f "usebackq delims=" %%a in ("%URLS%") do (
    Call :StringFormat "%%a"
    for /f "tokens=2 delims=[]" %%b in ('ping -n 1 !URL!') do set "ip=%%b"
        ping -n 1 !URL!>nul && set "msg=!URL! - !ip! ALive ok" && Call :Color 0A "     !msg!" 1 || set "msg=!URL! - !ip! Dead failed to respond" && Call :Color 0C "     !msg!" 1
        echo !msg! >> %LogFile%
    )
)
EndLocal
Start "" "%LogFile%" & TimeOut /T 5 /Nobreak>nul & exit
::************************************************************************************* 
:init
prompt $g
for /F "delims=." %%a in ('"prompt $H. & for %%b in (1) do rem"') do set "BS=%%a"
exit /b
::*************************************************************************************
:color
set nL=%3
if not defined nL echo requires third argument & pause > nul & goto :eof
if %3 == 0 (
    <nul set /p ".=%bs%">%2 & findstr /v /a:%1 /r "^$" %2 nul & del %2 2>&1 & goto :eof
) else if %3 == 1 (
    echo %bs%>%2 & findstr /v /a:%1 /r "^$" %2 nul & del %2 2>&1 & goto :eof
)
exit /b
::*************************************************************************************
:ReplaceString <Data> <String1> <String2>
(
    echo Wscript.echo Replace("%~1","%~2","%~3"^)
)>"%tmp%\%~n0.vbs"
for /f "delims=" %%a in ('Cscript /nologo "%tmp%\%~n0.vbs"') do ( set "URL=%%a" )
If Exist "%tmp%\%~n0.vbs" Del "%tmp%\%~n0.vbs"
exit /b
::*************************************************************************************
:StringFormat <URL>
(   
    echo Function StringReplace(Str^)
    echo    Str = Replace(Str,"http://",""^)
    echo    Str = Replace(Str,"https://",""^)
    echo    StringReplace = str
    echo End Function
    echo wscript.echo StringReplace("%~1"^)
)>"%tmp%\%~n0.vbs"
for /f "delims=" %%a in ('Cscript /nologo "%tmp%\%~n0.vbs"') do ( set "URL=%%a" )
If Exist "%tmp%\%~n0.vbs" Del "%tmp%\%~n0.vbs"
exit /b
::*************************************************************************************
:CreateDummyFile
(
    echo http://www.hyperdebrid.com
    echo http://www.fakirdebrid.net
    echo http://www.keepfiles.fr
    echo http://www.4shared.com 
    echo https://1fichier.com
    echo http://www.mega.co.nz
    echo http://www.mediafire.com
    echo http://www.uploaded.net
    echo http://www.oboom.com
    echo http://www.letitbit.net
    echo http://www.keep2share.cc
    echo http://alfafile.net
    echo https://www.bigfile.to
    echo http://www.dailymotion.com
    echo http://www.datafile.com
    echo http://www.Depfile.com
    echo http://www.Dropbox.com
    echo http://www.Extmatrix.com
    echo http://www.Fboom.me
    echo http://www.Filefactory.com
    echo http://www.Filesmonster.com
    echo http://www.Fshare.vn
    echo http://www.Keep2share.com
    echo http://www.Mega.nz
    echo http://www.Rapidgator.net
    echo http://www.Scribd.com
    echo http://www.Soundcloud.com
    echo http://www.Speedyshare.com
    echo http://www.Turbobit.net
    echo http://www.Vimeo.com
 )>%URLS%
start /b "" cmd /c "%~f0" & exit
::*************************************************************************************
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #change #color #batch
ADD COMMENT
Topic
Name
1+9 =