# Solved: Code (Fixed format issue)



## batscrptmod200 (May 17, 2012)

@echo off
color 0B
title Ping test
:askping
cls
set chk=
echo Enter = Default address
set /p chk=Address:
cls
if not defined chk (
(echo Default Ping!)&(ping 8.8.8.8)
) ELSE (
if %chk%==*.*.*.* (
(echo Custom Ping!)&(ping %chk%)
) ELSE(
(echo Incorrect Value!)&(pause&goto :askping)
)
:askquit
echo Press Enter to quit and y to restart
set chk=*.*.*.*
set /p chk=Restart?
if %chk%==*.*.*.* goto :EOF
if /i not %chk%==y (
(cls)&(goto :askquit)
) ELSE (
goto :askping
)


----------



## batscrptmod200 (May 17, 2012)

I use this batch file in the quick start area of explorers taskbar and wanted to change the code but am having issues with it not working?


batscrptmod200 said:


> @echo off color 0B title Ping test :askping cls set chk= echo Enter = Default address set /p chk=Address: cls if not defined chk ( (echo Default Ping!)&(ping 8.8.8.8) ) ELSE ( if %chk%==*.*.*.* ( (echo Custom Ping!)&(ping %chk%) ) ELSE( (echo Incorrect Value!)&(pause&goto :askping) ) :askquit echo Press Enter to quit and y to restart set chk=*.*.*.* set /p chk=Restart? if %chk%==*.*.*.* goto :EOF if /i not %chk%==y ( (cls)&(goto :askquit) ) ELSE ( goto :askping )


----------



## foxidrive (Oct 20, 2012)

This line will not check for a valid IP address if that was your intent.

if %chk%==*.*.*.* (


----------



## batscrptmod200 (May 17, 2012)

Thanx
I was trying to do that.
I guess i can't use an asterisk in the if statement?


----------



## foxidrive (Oct 20, 2012)

Are you trying to determine a valid IP address or just trying to filter out anything that is not numbers or a period?


----------



## Squashman (Apr 4, 2003)

Would be helpful if you put your code in code tags.


----------



## batscrptmod200 (May 17, 2012)

Just trying to filter anything that is not an ip address and i stuck with this

```
@echo off
color 0B
title Ping test
:askping
cls
set chk=
echo Enter = Default address
set /p chk=Address:
cls
if not defined chk (
(echo Default Ping!)&(ping 8.8.8.8)
) ELSE (
(echo Custom Ping!)&(ping %chk%)
)
:askquit
echo Press Enter to quit and y to restart
set chk=n
set /p chk=Restart?
if %chk%==n goto :EOF
if /i not %chk%==y (
(cls)&(goto :askquit)
) ELSE (
goto :askping
)
```


----------



## foxidrive (Oct 20, 2012)

Try this:


```
@echo off
color 0B
title Ping test
:askping
cls
set "chk="
set /p "chk=IP Address (Enter = Default address): "
cls
if not defined chk set chk=8.8.8.8
for /f "delims=0123456789." %%a in ("%chk%") do goto :askping
ping %chk%
echo.
set "chk="
set /p "chk=Press Enter to quit or y to restart: "
if /i "%chk%"=="y" goto :askping
```


----------



## batscrptmod200 (May 17, 2012)

Works good in 8 Thanx


----------

