Page 1 of 1

PING ADDRESS FROM REG QUERY Not Working...

Posted: 20 Jun 2012 15:15
by Dos_Probie
Hey Guys,

I got the following code below giving me my current Proxy address from the
registry but when I try to add in Ping its gives error and not working.. I think I am close but
if one of you Guru's can help I would really appreciate it..

Code: Select all

@echo off

for /F "eol= tokens=1* " %%a in ('REG Query "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v proxyserver /t REG_SZ 2^>nul ^| find "REG_SZ"') do set str=%%b
set str=%str:~10,20%
if '%str%'=='' (
ping -n 12 %str%
)

:Output
ping -n 12 %str%
echo Your Current Proxy Address Is: %str%

pause

Re: PING ADDRESS FROM REG QUERY Not Working...

Posted: 20 Jun 2012 17:18
by abc0502
what is the output of %str% ?

Re: PING ADDRESS FROM REG QUERY Not Working...

Posted: 20 Jun 2012 19:56
by Dos_Probie
got it working now , was trying to ping off port, corrected code below.

Code: Select all

for /F "eol= tokens=1* " %%a in ('REG Query "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v proxy /t REG_SZ 2^>nul ^| find "REG_SZ"') do set str=%%b
set str=%str:~10,20%

:Output
ping -n 12 %str%