I am trying to color specific parts of the text and have managed to succeed partially. I am using the call :colorEcho line to color the text. The line that doesn't work is line 72. It works the first time, in line 54, but not the next. I was just wondering if anyone here knows how to fix this.
BTW I got the code from here
#echo off
SETLOCAL EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
set "DEL=%%a"
)
:start
echo You have been studying for years for this moment, to create a human master race, all you have to do is complete the circuit connecting the lightning rods to the speciman. Do you do it?
ping -n 2 1.1.1.1 > nul
echo.
echo 1) Connect the circuit.
echo 2) No, you take your work and burn it.
echo.
set /p Choice=Choose Now:
if "%Choice%"=="1" goto awaken
if "%Choice%"=="2" goto end1
:awaken
cls
echo 3
timeout /t 2 /nobreak >nul
cls
echo 2
timeout /t 2 /nobreak >nul
cls
echo 1
timeout /t 2 /nobreak >nul
cls
echo CRACK!!
timeout /t 2 /nobreak >nul
cls
echo Lightning strikes the rod and you see movement coming from the speciman under the sheet on the table.
pause
cls
echo The creature sits up. It is more disgusting then you ever could have imagined, you are terrified. It stares at you with mindless eyes, what do you do?
echo.
echo 1) Run for your life.
echo 2) Stay in the Room.
echo.
set /p Choice=Choose Now:
if "%Choice%"=="1" goto run4life
if "%Choice%"=="2" goto staycalm
:run4life [
cls
]
:staycalm [
cls
echo The monster stares at you.
timeout /t 4 /nobreak >nul
echo It screams
timeout /t 1 /nobreak >nul
call :colorEcho 0a "RAAAAUUUGGGHHH"
timeout /t 2 /nobreak >nul
echo.
echo 1) Run for your life.
echo 2) Stay in the Room.
echo.
set /p Choice=Choose Now:
if "%Choice%"=="1" goto run4life
if "%Choice%"=="2" goto staycalm2
]
:staycalm2
[
cls
timeout /t 3 /nobreak >nul
echo You hear a knock at the door.
call :colorEcho 0a " Hello, anyone there? Someone reported hearing a scream from your residence."
echo.
echo How should you react?
echo.
echo 1) Jump out the window.
echo 2) Answer the door.
echo.
set /p Choice=Choose Now:
if "%Choice%"=="1" goto run4life
if "%Choice%"=="2" goto staycalm3
]
:staycalm3
[
cls
call :colorEcho 0c "Oh yes, I was just scared by a spider."
echo.
timeout /t 2 /nobreak >nul
echo.
call :colorEcho ob "uhhmmm..."
timeout /t 2 /nobreak >nul
echo.
echo.
call :colorEcho 0b "Well, do you mind if I come in just to check around?
]
:end 1
cls
echo Congratulations, you have completed the game without causing anyone to die!
echo.
echo 1) Exit
echo 2) Play Again!
echo.
set /p Choice=Choose Now:
if "%Choice%"=="1" goto
if "%Choice%"=="2" goto first
:colorEcho
echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1i
You are using a primitive version of the color print routine that cannot handle characters that are invalid in file names: \, /, :, ", ?, *, &, |, <, >. The version you are using attempts to create a file with a name equal to your displayed string, so it cannot work for your question string.
The top three answers at How to have multiple colors in a Windows batch file? have more sophisticated versions (more complicated), that can handle nearly any character.
The question mark in the text is screwing it up. By the way, I think you mean line 70 is the one that's failing.
Related
Having a latency less than 600 but greater than 90 continues to go to :FAST CONNECTION. It should be going to :MODERATE CONNECTION.
#ECHO off
MODE CON:cols=38 lines=11
:LOOP
SET a=3000
FOR /f "tokens=7 delims== " %%G IN ('PING -4 -n 1 8.8.8.8^| FIND "TTL" ') DO SET a=%%G
CLS
IF %a% EQU 3000 (GOTO :NO CONNECTION) ELSE (GOTO :SPEED)
:SPEED
IF %a% GTR 600 (GOTO :SLOW CONNECTION)else (IF %a% LSS 90 (GOTO :FAST CONNECTION) else (GOTO :MODERATE CONNECTION))
TIMEOUT /T 2 > NUL
:NO CONNECTION
COLOR 4F
ECHO.
ECHO.
ECHO --- NO CONNECTION ---
ECHO.
ECHO CHECK YOUR NETWORK CONNECTION
TIMEOUT /T 2 > NUL
CLS
ECHO.
ECHO.
ECHO *** NO CONNECTION ***
ECHO.
ECHO CHECK YOUR NETWORK CONNECTION
TIMEOUT /T 2 > NUL
CLS
ECHO.
ECHO.
ECHO !!! NO CONNECTION !!!
ECHO.
ECHO CHECK YOUR NETWORK CONNECTION
TIMEOUT /T 2 > NUL
GOTO :END
:FAST CONNNECTION
COLOR 2F
ECHO.
ECHO YOU CURRENTLY HAVE A
ECHO FAST CONNECTION TO INTERNET: %a%
ECHO.
ECHO APPLICATIONS AND FILE TRANSFERS
ECHO WILL RUN AT A GREAT RATE
ECHO.
ECHO FAST 0 - 10
ECHO MODERATE 11 - 20
ECHO SLOW 600 - 3000
TIMEOUT /T 3 > NUL
GOTO :END
:MODERATE CONNECTION
COLOR 6F
ECHO.
ECHO YOU CURRENTLY HAVE A
ECHO MODERATE CONNECTION TO THE INTERNET : %a%
ECHO.
ECHO APPLICATIONS AND FILE TRANSFERS
ECHO WILL RUN AT A SO/SO RATE
ECHO.
ECHO FAST 0 - 10
ECHO MODERATE 11 - 20
ECHO SLOW 600 - 3000
TIMEOUT /T 3 > NUL
GOTO :END
:SLOW CONNECTION
COLOR 4F
ECHO.
ECHO YOU CURRENTLY HAVE A
ECHO SLOW CONNECTION TO INTERNET: %a%
ECHO.
ECHO ALTERNATE OR CONTINGENCY
ECHO NETWORK WILL RUN AT A SLOWED RATE
ECHO.
ECHO FAST 0 - 10
ECHO MODERATE 11 - 20
ECHO SLOW 600 - 3000
TIMEOUT /T 3 > NUL
GOTO :END
:END
GOTO :LOOP
FOR /f "tokens=7 delims== " %%G IN ('PING -4 -n 1 8.8.8.8^| FIND "TTL" ') DO SET a=%%G
On a US-EN machine a gets set to a number with the time unit ms appended e.g. 100ms.
This causes the following comparisons to work as string comparisons (lexicographically), not number comparisons, so for example:
C:\etc>if 100ms LSS 11 #echo ???
???
C:\etc>if 100ms LSS 10 #echo ???
C:\etc>
The quick-and-dirty solution in this case is to strip the ms suffix right after the for loop.
set "a=%a:~0,-2%"
Note: this may not - and will likely not - work on localized Windows other than US-EN.
For the purpose of this demonstration, I've set a timeout of 3 seconds at the end of the script, you can adjust this as you please.
Your main issue is that you are using labels with spaces, you cannot do that. Second issue is that, as already mentioned by #Mofi in a comment, depending on your keyboard settings (language) different items are assigned to %a%.
I however suggest that you do 2 pings and use the average result, instead of ttl.
As a side note, ping (using ICMP) is for diagnostics and will not always get priority.
#echo off
MODE CON:cols=38 lines=11
:test
set latency=3000
#echo off
for /f "tokens=2delims==, " %%i in ('ping -4 -n 2 8.8.8.8^| find /i "average" ') do set "latency=%%i"
set latency=%latency:ms=%
if %latency% gtr 600 if %latency% lss 3000 (
color 4F
echo(
echo Slow connection %latency%
echo(
)
if %latency% geq 3000 (
color 4F
echo(
echo Connection seems down %latency%
echo(
)
if %latency% lss 90 (
color 2F
echo(
echo Fast Connection %latency%
echo(
)
if %latency% gtr 90 if %latency% lss 600 (
color 6F
echo(
echo Moderate Connection %latency%
echo(
)
(timeout /t 3)>nul 2>&1 & cls & goto test
You will note, for obvious reasons I removed some of the noise you had, you can add all the echo( back if you want, but I do not see the purpose of it. I also removed all the goto labels, as it is not required.
Please begin by taking note of my comment, which tells you that this code will not provide a measurable indication of your internet connection's speed.
Now, without radically changing your script and layout, you could probably use wmic with Win32_PingStatus, instead on ping. This should ensure that your variable always has the response time in milliseconds, if one is returned within the allowed timespan:
Example, (Just change the Host Address on line 5 as needed):
#Echo Off
SetLocal EnableExtensions DisableDelayedExpansion
Mode CON:Cols=45 Lines=11
Set "HA=8.8.8.8"
:Loop
Color
Set "RT="
For /F EOL^=R %%G In ('%__AppDir__%wbem\WMIC.exe Path Win32_PingStatus Where^
"Address='%HA%'" Get ResponseTime 2^>NUL')Do For %%H In (%%G)Do Set "RT=%%H"
If Not Defined RT GoTo None
If %RT% Gtr 600 GoTo Slow
If %RT% Gtr 90 GoTo Moderate
:Fast
Color 2F
Echo=
Echo YOU CURRENTLY HAVE A
Echo FAST CONNECTION TO INTERNET: %RT%ms
Echo=
Echo APPLICATIONS AND FILE TRANSFERS
Echo WILL RUN AT A GREAT RATE
Echo=
Echo FAST : 0 - 10
Echo MODERATE : 11 - 20
Echo SLOW : 600 - 3000
Echo=
%__AppDir__%timeout.exe /T 5 /NoBreak >NUL
GoTo Loop
:Moderate
Color 6F
Echo=
Echo YOU CURRENTLY HAVE A
Echo MODERATE CONNECTION TO THE INTERNET: %RT%ms
Echo=
Echo APPLICATIONS AND FILE TRANSFERS
Echo WILL RUN AT A SO/SO RATE
Echo=
Echo FAST : 0 - 10
Echo MODERATE : 11 - 20
Echo SLOW : 600 - 3000
Echo=
%__AppDir__%timeout.exe /T 5 /NoBreak >NUL
GoTo Loop
:Slow
ClS
Color 4F
Echo=
Echo YOU CURRENTLY HAVE A
Echo SLOW CONNECTION TO INTERNET: %RT%ms
Echo=
Echo ALTERNATE OR CONTINGENCY NETWORK
Echo WILL RUN AT A GREAT RATE
Echo=
Echo FAST : 0 - 10
Echo MODERATE : 11 - 20
Echo SLOW : 600 - 3000
Echo=
%__AppDir__%timeout.exe /T 5 /NoBreak >NUL
GoTo Loop
:None
ClS
Color 4F
Echo=
Echo --- NO CONNECTION ---
Echo=
Echo CHECK YOUR NETWORK CONNECTION
Echo=
%__AppDir__%timeout.exe /T -1
GoTo Loop
Please be aware, that I do not know why you've asked the code to loop back to the ping, so if that's not your overall intention, for now you'll need to use CTRL+C to stop if from looping.
#echo off
:start
cls
color e
echo YOU HAVE WON $1,000,000! WHAT WILL YOU DO?
echo.
echo =================
echo -Take it (1)
echo -Leave it (2)
echo -Double it (3)
echo =================
echo.
timeout /t 1 >nul 2>&1
color a
timeout /t 1 >nul 2>&1
color b
timeout /t 1 >nul 2>&1
color e
timeout /t 1 >nul 2>&1
color a
timeout /t 1 >nul 2>&1
color b
timeout /t 1 >nul 2>&1
color e
timeout /t 1 >nul 2>&1
color a
timeout /t 1 >nul 2>&1
color b
timeout /t 1 >nul 2>&1
color e
timeout /t 1 >nul 2>&1
color a
timeout /t 1 >nul 2>&1
color b
timeout /t 1 >nul 2>&1
color e
set /p INPUT=Please specify your answer:
If /i "%INPUT%" == "1" goto 1
If /i "%INPUT%" == "2" goto 2
If /i "%INPUT%" == "3" goto 3
I have this code above, and there is a really annoying thing that I can't figure out. So you can see I am repeatedly changing the colors, but you can see it gets in the way of the next command. Is there a way I can make it like in the background until the answer has been chosen? (1, 2, or 3).
Using start /B with an aux script does the trick.
The aux script exits when it finds that a temporary file exists. Lame but works.
my mockup main routine (call it main.bat)
#echo off
:start
cls
color e
echo YOU HAVE WON $1,000,000! WHAT WILL YOU DO?
echo.
echo =================
echo -Take it (1)
echo -Leave it (2)
echo -Double it (3)
echo =================
echo.
start /B %~dp0\color_cycling.bat
:err
set /p INPUT=Please specify your answer:
If /i "%INPUT%" == "1" goto 1
If /i "%INPUT%" == "2" goto 2
If /i "%INPUT%" == "3" goto 3
goto err
:1
echo.> %TEMP%\stopcol
echo take it
set /p SURE=are you sure?
pause
:2
echo.> %TEMP%\stopcol
echo leave it
pause
My color_cycling.bat routine
#echo off
del %TEMP%\stopcol 2>NUL >NUL
:lab
for %%i in (a b e) do (
timeout /t 1 >nul 2>&1
color %%i
if exist %TEMP%\stopcol exit
)
goto lab
Nice effect from year 1977 indeed!
I want to make is so that in my game it doesn't just continue the code if you press enter without entering a choice. How can I do this? By this I mean if you press enter without entering a 1, 2, 3, etc. Is there a command to allow me to do this?
#echo off
SETLOCAL EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
set "DEL=%%a"
)
:start
echo You have been studying for years for this moment, to create a human master race, all you have to do is complete the circuit connecting the lightning rods to the speciman. Do you do it?
ping -n 2 1.1.1.1 > nul
echo.
echo 1) Connect the circuit.
echo 2) No, you take your work and burn it.
echo.
set /p Choice=Choose Now:
if "%Choice%"=="1" goto awaken
if "%Choice%"=="2" goto end1
:awaken
cls
echo 3
timeout /t 2 /nobreak >nul
cls
echo 2
timeout /t 2 /nobreak >nul
cls
echo 1
timeout /t 2 /nobreak >nul
cls
echo CRACK!!
timeout /t 2 /nobreak >nul
cls
echo Lightning strikes the rod and you see movement coming from the speciman under the sheet on the table.
pause
cls
echo The creature sits up. It is more disgusting then you ever could have imagined, you are terrified. It stares at you with mindless eyes, what do you do?
echo.
echo 1) Run for your life.
echo 2) Stay in the Room.
echo.
set /p Choice=Choose Now:
if "%Choice%"=="1" goto run4life
if "%Choice%"=="2" goto staycalm
:run4life [
cls
]
:staycalm [
cls
echo The monster stares at you.
timeout /t 4 /nobreak >nul
echo It screams
timeout /t 1 /nobreak >nul
call :colorEcho 0a "RAAAAUUUGGGHHH"
timeout /t 2 /nobreak >nul
echo.
echo 1) Run for your life.
echo 2) Stay in the Room.
echo.
set /p Choice=Choose Now:
if "%Choice%"=="1" goto run4life
if "%Choice%"=="2" goto staycalm2
]
:staycalm2
[
cls
timeout /t 3 /nobreak >nul
echo You hear a knock at the door.
call :colorEcho 0a " Hello, anyone there? Someone reported hearing a scream from your residence."
echo.
echo How should you react?
echo.
echo 1) Jump out the window.
echo 2) Answer the door.
echo.
set /p Choice=Choose Now:
if "%Choice%"=="1" goto run4life
if "%Choice%"=="2" goto staycalm3
]
:staycalm3
[
cls
call :colorEcho 0c "Oh yes, I was just scared by a spider."
echo.
timeout /t 2 /nobreak >nul
echo.
call :colorEcho ob "uhhmmm..."
timeout /t 2 /nobreak >nul
echo.
echo.
call :colorEcho 0b "Well, do you mind if I come in just to check around?
]
:end 1
cls
echo Congratulations, you have completed the game without causing anyone to die!
echo.
echo 1) Exit
echo 2) Play Again!
echo.
set /p Choice=Choose Now:
if "%Choice%"=="1" goto
if "%Choice%"=="2" goto first
:colorEcho
echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1i
This is one way:
echo.
:loop1
set "Choice="
set /p Choice=Choose Now:
if "%Choice%"=="1" goto run4life
if "%Choice%"=="2" goto staycalm
goto :loop1
I'm working on a program which generates the day's weather for D&D games. I want the program to display a warning in red text when a storm is generated so the DM is aware that this weather is not typical. To reduce the number of keystrokes, it must do this on the same screen as the text detailing the weather itself.
Currently for a storm's entry I have this:
:des4a
cls
type c:\AutoDM\WeatherGen\data\forcast1.txt
color 0c
echo There is an Ashstorm!
color 0a
echo.
echo It is %temp% degrees and the sky is invisible threw the thick
echo billowing clouds of ash.
echo.
echo # Survival checks to light a fire are at +15.
echo # Small unprotected flames will be snuffed out.
echo # Non-firearm ranged attacks are at a -8 to hit.
echo # Preception checks take a -10 for every 10 feet of distance.
echo # Survival checks to get along in the wild are at +15.
echo # Stealth checks are at a +5.
echo.
echo SPECIAL!
echo.
set /a die=6
set /a inches=%random%%%die+1
echo # The ashstorm will deposit %inches% inches of ash durring its
echo durration.
echo # Tracking a target after an ashstorm is at a +15.
type c:\AutoDM\WeatherGen\data\forcast2.txt
echo.
echo.
pause
goto menu
The type commands are calling text documents which contain a header and footer for each entry to help the program look professional and provide a border to assist with word wrap. Thy cannot be removed. DO not suggest something which would make me unable to use the type commands as they currently exist please. Please understand that this red text line will be added to a lot of different parts of the program, each time there is a storm for each and every biome in the generator. I would prefer it to not be more then just 2 or 3 lines of code (But if there is only one way to do it well...)
Can I have the one line in red and the rest in green? Or should I have the program beep to call attention to the fact? Do you have a better and simpler idea? How do I do this?
I was having the same problem yesterday, I did some research and this worked for me.
EDIT: This is NOT the same code as the other one.
#Echo Off
SETLOCAL EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
set "DEL=%%a"
)
call :colorEcho 0a "This is colored green with a black background!"
echo.
call :colorEcho a0 "This is colored black with a green background!"
echo.
pause
exit
:colorEcho
echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1i
it does this:
All you need to do to fit this is put the part from SETLOCAL EnableDel... to ) to the beginning of your code (If your code starts with #echo off then put it under that) and also put the part from :colorEcho to del %~2 at the exact bottom of your script (NOTHING UNDERNEATH!)
Now between you notice
call :colorEcho 0a "This is colored green with a black background!"
echo.
call :colorEcho a0 "This is colored black with a green background!"
echo.
pause
exit
Explained line by line:
First line (call :colorEcho 0a "This is colored green with a black background!"): This is a colored echo, it suprisingly says This is colored green with a black background! in 0a (Black Bg, Green Text)
Second line (echo.) prints a newline, since our colored echo doesn't print one.
SO
Let's say you wanted to say "Hello World" in Hello being yellow and World being green.
Example!
#Echo Off
SETLOCAL EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
set "DEL=%%a"
)
call :colorEcho 0e "Hello "
call :colorEcho 0a " World"
pause
exit
:colorEcho
echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1i
This is what it does:
I hope this is understandable!
EDIT: Make sure the program exits before it could reach :colorEcho
Script from here:
How to have multiple colors in a Windows batch file?
a little modified (simplyfied):
#echo off
SETLOCAL EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
set "DEL=%%a"
)
echo next line in another color:
call :ColorText 0c "There is an Ashstorm!"
echo this was red.
call :ColorText 0a "you survived it."
goto :eof
:ColorText
echo off
echo %DEL% > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1
goto :eof
It was a link in the very first answer of "possible duplicate: How to change the text color of comments line in a batch file
"
#Echo Off
SETLOCAL EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"')
do (
set "DEL=%%a"
)
call :colorEcho 0c "HyperBeast"
echo.
call :colorEcho 0c "NeonRider"
echo.
call :colorEcho 0d "Djinn"
echo.
call :colorEcho 0d "Eco"
echo.
call :colorEcho 0d "MonkeyBuisness"
echo.
call :colorEcho 05 "GrandPrix"
echo.
call :colorEcho 05 "PolePosition"
echo.
call :colorEcho 05 "Heat"
echo.
call :colorEcho 05 "WormGod"
echo.
call :colorEcho 09 "Origami"
echo.
call :colorEcho 09 "Man'o'war"
echo.
call :colorEcho 09 "Valence"
echo.
call :colorEcho 09 "BronzeDeco"
echo.
call :colorEcho 09 "ArmorCore"
echo.
call :colorEcho 09 "EliteBuild"
echo.
pause
exit
:colorEcho
echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1\
You can try this script. Use it to print any text with any color in any screen position. It does not use temporary files, but your system must have debug.exe executable (Windows native):
#echo off
rem Script written by BrendanSilva [bl8086]
rem You need DEBUG.EXE executable in your system.
setlocal enabledelayedexpansion
set /a _er=0
set /a _n=0
set _ln=%~4
goto init
:howuse ------------------------------------------------------------------------
echo.
echo ECOL.BAT - v2.0
echo Print colored text as batch script without temporary files.
echo Written by bl8086
echo.
echo Syntax:
echo ECOL.BAT [COLOR] [X] [Y] "Insert your text here"
echo COLOR value must be a hexadecimal number like "color /?" information
echo.
echo Example:
echo ECOL.BAT F0 20 30 "640K ought to be enough for anybody."
echo.
goto :eof
:error ------------------------------------------------------------------------
set /a "_er=_er | (%~1)"
goto :eof
:gcnvhx ------------------------------------------------------------------------
set _cvhx=
set /a _cvint=%~1
:cnvhx
set /a "_gch = _cvint & 0xF"
set _cvhx=!nsys:~%_gch%,1!%_cvhx%
set /a "_cvint = _cvint >> 4"
if !_cvint! neq 0 goto cnvhx
goto :eof
:init --------------------------------------------------------------------------
if "%~4"=="" call :error 0xff
(
set /a _cl=0x%1
call :error !errorlevel!
set _cl=%1
call :error "0x!_cl! ^>^> 8"
set /a _px=%2
call :error !errorlevel!
set /a _py=%3
call :error !errorlevel!
) 2>nul 1>&2
if !_er! neq 0 (
echo.
echo ERROR: value exception "!_er!" occurred. Check memory out.
echo.
goto howuse
)
set nsys=0123456789ABCDEF
set /a cnb=0
set /a cnl=0
set _cvhx=0
set _cvint=0
set _cvmhx=0
:parse -------------------------------------------------------------------------
set _ch=!_ln:~%_n%,1!
if "%_ch%"=="" goto perform
set /a "cnb += 1"
if %cnb% gtr 7 (
set /a cnb=0
set /a "cnl += 1"
)
set bln%cnl%=!bln%cnl%! "!_ch!" %_cl%
set /a "_n += 1"
goto parse
:perform -----------------------------------------------------------------------
set /a "in = ((_py * 0xA0) + (_px << 1)) & 0xFFFF"
call :gcnvhx %in%
set ntr=!_cvhx!
set /a jmp=0xe
set bl8086str=echo.h 0 0
#for /l %%x in (0,1,%cnl%) do (
set bl8086str=!bl8086str!^&echo.eb800:!ntr! !bln%%x!
set /a "in=!jmp! + 0x!ntr!"
call :gcnvhx !in!
set ntr=!_cvhx!
set /a jmp=0x10
)
(
echo %bl8086str%
echo.q
) |debug >nul 2>&1
Old school trick:
echo =======================================================================================================================
echo [37m[0;1;36m*************************************************************************
echo ***** ***** ***** [31mWiindows 10 Networking [36m***** ***** *****
echo *************************************************************************[37m[0;1;37m
echo echo [37m[0;1;32m
echo =======================================================================================================================
cut and paste - I never could find doc's on this type of coding [?] used to be a forward arrow in DOS it was fun in my Autoexec,bat file. hope it helps some hacker - they sure have helped me, Thanks!
I'm trying to make a Batch file that will increment a variable by 1 each time it loops, and then check if the variable is equal to 5, and if it isn't, it loops again. I know there's probably a while loop for this, but I didn't know how to do that, and I'm just enjoying learning Batch for fun right now
Here's the code, it doesn't work the way it should, it just displays a 0: and then does nothing else. So how would I go about fixing it? I have a feeling I'm setting and incrementing the variable wrong, and maybe it's confused about the 2 if statements? (Does it have an else if....?) Anyways, thanks for the help
#echo off
set /p i=0:
goto A
:A
set /p i=i+1:
if i != 5 goto C
if i == 5 goto B
:C
echo Test :D
:B
pause>nul
Note: I don't know a lot of Batch and I'm not a pro, but I like to learn and I'm just doing this for future reference, and because I enjoy it. So, this code probably isn't good, but I want to know how I can accomplish this.
This is a way to simulate the while loop you are trying to accomplish. Only one goto is needed:
#echo off
set /a x=0
:while
if %x% lss 5 (
echo %x%
pause>nul
set /a x+=1
goto :while
)
echo Test :D
You can do that with a simple FOR command :
for /l %%x in (0,1,100) do (
echo %%x
)
You can replace 100 by the number you want
To set a numerical value to a variable, you may use the /a switch:
The /A switch specifies that the string to the right of the equal sign
is a numerical expression that is evaluated.
(Type SET /? for all the help).
Second, check your goto flow - this never loops back to A.
Third, check the syntax of the if expression (!= doesn't exist in batch).
This should work:
#echo off
set var1=0
:loop
set /a var1=%var1%+1
echo %var1%
if %var1% EQU 5 (
goto :end
) else (
goto :loop
)
:end
pause
#echo off
set a=0
:Count
set /a a=a+1
echo %a%
goto Count
try this:
#if (#CodeSection == #Batch) #then
#echo off
:a
cls
color c
echo --------------
echo start:
echo --------------
set /p start=
cls
echo --------------
echo start: %start%
echo --------------
echo --------------
echo stop:
echo --------------
set /p stop=
cls
echo --------------
echo start: %start%
echo --------------
echo --------------
echo stop: %stop%
echo --------------
echo.
echo.
echo Start in:
timeout /t 2 /nobreak >nul
echo. 5
timeout /t 1 /nobreak >nul
echo. 4
timeout /t 1 /nobreak >nul
echo. 3
timeout /t 1 /nobreak >nul
echo. 2
timeout /t 1 /nobreak >nul
echo. 1
timeout /t 1 /nobreak >nul
cls
echo --------------
echo start: %start%
echo --------------
echo --------------
echo stop: %stop%
echo --------------
echo.
echo.
echo.
echo ============================================
set SendKeys=CScript //nologo //E:JScript "%~F0"
%SendKeys% ">----"
%SendKeys% "{enter}"
:while
echo %start%
%SendKeys% "%start%"
%SendKeys% "{enter}"
set /a start=start+1
timeout /t 1 /nobreak >nul
if %start% leq %stop% goto :while
goto :end
:end
echo ============================================
%SendKeys% ">----"
%SendKeys% "{enter}"
:c
echo count again? Y/N
set /p return=
if %return% == Y goto :a
if %return% == N goto :b
goto :c
:b
#end
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));