<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; CMD/BAT: Определить шлюз или default route?]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=6793</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=6793&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «CMD/BAT: Определить шлюз или default route?».]]></description>
		<lastBuildDate>Wed, 29 Feb 2012 06:52:17 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: CMD/BAT: Определить шлюз или default route?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=57333#p57333</link>
			<description><![CDATA[<p>Меня устроил мой вариант.. я слегка модернизировал ваш и получил вот это:</p><div class="codebox"><pre><code>echo off
setlocal ENABLEDELAYEDEXPANSION

set n=-1
::wmic nicconfig where ipenabled=true get DefaultIPGateway /format:value
for /f %%x in (&#039;wmic nicconfig where ipenabled^=true get DefaultIPGateway /format:value ^| find /i &quot;DefaultIPGateway&quot;&#039;) do (
    set /a n=!n! + 1
    set &quot;%%x&quot;
    set DefaultIPGateway=!DefaultIPGateway:&quot;=!
    set DefaultIPGateway=!DefaultIPGateway:{=!
    set DefaultIPGateway=!DefaultIPGateway:}=!
    set DefaultIPGateway_!n!=!DefaultIPGateway!
)

set newname=%COMPUTERNAME%_%DATE%
 echo !%newname% &gt;&gt; C:\inet.log

for /l %%x in (0,1,!n!) do (
    echo !DefaultIPGateway_%%x! &gt;&gt; C:\inet.log
)</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (stir)]]></author>
			<pubDate>Wed, 29 Feb 2012 06:52:17 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=57333#p57333</guid>
		</item>
		<item>
			<title><![CDATA[Re: CMD/BAT: Определить шлюз или default route?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=57309#p57309</link>
			<description><![CDATA[<p>Делаю так<br /></p><div class="codebox"><pre><code>@ECHO Alive work fine - %DATE%%TIME% via !DefaultIPGateway_%%x! &gt;&gt; C:\inet.log</code></pre></div><p>В итоге получаю </p><div class="quotebox"><blockquote><p>Alive work fine - 28.02.201218:07:48,60 via !DefaultIPGateway_%x!</p></blockquote></div><p>Что делаю не верно?</p>]]></description>
			<author><![CDATA[null@example.com (Valera)]]></author>
			<pubDate>Tue, 28 Feb 2012 14:08:59 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=57309#p57309</guid>
		</item>
		<item>
			<title><![CDATA[Re: CMD/BAT: Определить шлюз или default route?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=57143#p57143</link>
			<description><![CDATA[<p>так же</p><p>...(<br />&nbsp; &nbsp; echo !DefaultIPGateway_%%x! &gt;&gt; C:\inet.log<br />)</p>]]></description>
			<author><![CDATA[null@example.com (smaharbA)]]></author>
			<pubDate>Wed, 22 Feb 2012 03:51:16 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=57143#p57143</guid>
		</item>
		<item>
			<title><![CDATA[Re: CMD/BAT: Определить шлюз или default route?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=57136#p57136</link>
			<description><![CDATA[<p>Еще вопрос, как мне добавить в эту часть<br /></p><div class="codebox"><pre><code>@echo &quot;Inet work - %DATE%%TIME%&quot; &gt;&gt; C:\inet.log</code></pre></div><p>Вывод из <br /></p><div class="codebox"><pre><code>echo off
setlocal ENABLEDELAYEDEXPANSION

set n=-1
::wmic nicconfig where ipenabled=true get DefaultIPGateway /format:value
for /f %%x in (&#039;wmic nicconfig where ipenabled^=true get DefaultIPGateway /format:value ^| find /i &quot;DefaultIPGateway&quot;&#039;) do (
    set /a n=!n! + 1
    set &quot;%%x&quot;
    set DefaultIPGateway=!DefaultIPGateway:&quot;=!
    set DefaultIPGateway=!DefaultIPGateway:{=!
    set DefaultIPGateway=!DefaultIPGateway:}=!
    set DefaultIPGateway_!n!=!DefaultIPGateway!
)
for /l %%x in (0,1,!n!) do (
    echo !DefaultIPGateway_%%x!
)</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Valera)]]></author>
			<pubDate>Tue, 21 Feb 2012 13:13:29 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=57136#p57136</guid>
		</item>
		<item>
			<title><![CDATA[Re: CMD/BAT: Определить шлюз или default route?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=57132#p57132</link>
			<description><![CDATA[<p>Спасибо.</p><div class="quotebox"><blockquote><p>echo off</p></blockquote></div><p>Заменить на <br />@echo off</p><p>Этот способ даже в 7ке нормально отрабатывает.</p>]]></description>
			<author><![CDATA[null@example.com (Valera)]]></author>
			<pubDate>Tue, 21 Feb 2012 07:16:12 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=57132#p57132</guid>
		</item>
		<item>
			<title><![CDATA[Re: CMD/BAT: Определить шлюз или default route?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=57121#p57121</link>
			<description><![CDATA[<div class="codebox"><pre><code>echo off
setlocal ENABLEDELAYEDEXPANSION

set n=-1
::wmic nicconfig where ipenabled=true get DefaultIPGateway /format:value
for /f %%x in (&#039;wmic nicconfig where ipenabled^=true get DefaultIPGateway /format:value ^| find /i &quot;DefaultIPGateway&quot;&#039;) do (
    set /a n=!n! + 1
    set &quot;%%x&quot;
    set DefaultIPGateway=!DefaultIPGateway:&quot;=!
    set DefaultIPGateway=!DefaultIPGateway:{=!
    set DefaultIPGateway=!DefaultIPGateway:}=!
    set DefaultIPGateway_!n!=!DefaultIPGateway!
)
for /l %%x in (0,1,!n!) do (
    echo !DefaultIPGateway_%%x!
)</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (smaharbA)]]></author>
			<pubDate>Mon, 20 Feb 2012 18:56:47 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=57121#p57121</guid>
		</item>
		<item>
			<title><![CDATA[Re: CMD/BAT: Определить шлюз или default route?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=57112#p57112</link>
			<description><![CDATA[<div class="quotebox"><cite>smaharbA пишет:</cite><blockquote><p>Пойдет ?<br /></p><div class="codebox"><pre><code>for /f &quot;tokens=3&quot; %%x in (&#039;route print 0.0.0.0 ^| find &quot;0.0.0.0&quot;&#039;) do echo %%x</code></pre></div></blockquote></div><p>Данный способ не всегда отрабатывает верно.<br />Может есть еще пути определения? <br />wmic?</p><p>NICCONFIG GET DefaultIPGateway выдаст, примерно вот такую инфу. <br /></p><div class="quotebox"><blockquote><p>wmic:root\cli&gt;NICCONFIG GET DefaultIPGateway<br />DefaultIPGateway<br />{&quot;192.168.2.101&quot;}</p></blockquote></div><p>Но вот вопрос, как убрать пробелы и не нужные знаки?</p>]]></description>
			<author><![CDATA[null@example.com (Valera)]]></author>
			<pubDate>Mon, 20 Feb 2012 14:17:17 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=57112#p57112</guid>
		</item>
		<item>
			<title><![CDATA[Re: CMD/BAT: Определить шлюз или default route?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=56735#p56735</link>
			<description><![CDATA[<p>Отличный, ход. Я об этом не подумал.</p>]]></description>
			<author><![CDATA[null@example.com (Valera)]]></author>
			<pubDate>Mon, 13 Feb 2012 07:45:44 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=56735#p56735</guid>
		</item>
		<item>
			<title><![CDATA[Re: CMD/BAT: Определить шлюз или default route?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=56732#p56732</link>
			<description><![CDATA[<p>Пойдет ?<br /></p><div class="codebox"><pre><code>for /f &quot;tokens=3&quot; %%x in (&#039;route print 0.0.0.0 ^| find &quot;0.0.0.0&quot;&#039;) do echo %%x</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (smaharbA)]]></author>
			<pubDate>Mon, 13 Feb 2012 07:36:14 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=56732#p56732</guid>
		</item>
		<item>
			<title><![CDATA[Re: CMD/BAT: Определить шлюз или default route?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=56729#p56729</link>
			<description><![CDATA[<p>Поясню в windows шлюз можно посмотреть командой ipconfig /all или route print<br />===========================================================================<br />Постоянные маршруты:<br />&nbsp; Сетевой адрес&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Маска&nbsp; &nbsp; Адрес шлюза&nbsp; &nbsp; &nbsp; Метрика<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0.0.0.0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0.0.0.0&nbsp; &nbsp; 192.168.1.200&nbsp; По умолчанию<br />===========================================================================</p><p>Или</p><p>&nbsp; &nbsp;Основной шлюз. . . . . . . . . : 192.168.1.200<br />&nbsp; &nbsp;DNS-серверы. . . . . . . . . . . : 192.168.1.101<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;192.168.1.200<br />Так вот интересует как через cmd сценарий получить именно 192.168.1.200, только этот набор цифр, а остальное обрезать. </p><p>Еще можно получить с помощью пару средств, но они реже используются.</p>]]></description>
			<author><![CDATA[null@example.com (Valera)]]></author>
			<pubDate>Mon, 13 Feb 2012 04:43:21 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=56729#p56729</guid>
		</item>
		<item>
			<title><![CDATA[Re: CMD/BAT: Определить шлюз или default route?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=56678#p56678</link>
			<description><![CDATA[<p>не совсем понял, определение текущего шлюза или переназначение основного шлюза ?<br />route change ... ?</p>]]></description>
			<author><![CDATA[null@example.com (smaharbA)]]></author>
			<pubDate>Sat, 11 Feb 2012 12:33:19 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=56678#p56678</guid>
		</item>
		<item>
			<title><![CDATA[CMD/BAT: Определить шлюз или default route?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=56601#p56601</link>
			<description><![CDATA[<p>Добрый день, всем. </p><p>Есть вот такой cmd скрипт<br /></p><div class="codebox"><pre><code>@echo off
SET GW101=192.168.2.101
SET GW102=192.168.2.102
SET GW222=192.168.2.222

SET PING=ping -n 2 ya.ru &gt; nul
SET GATEWAY101=netsh interface ip set address name=&quot;local&quot; gateway=%GW101% gwmetric=0
SET GATEWAY102=netsh interface ip set address name=&quot;local&quot; gateway=%GW102% gwmetric=0
SET GATEWAY222=netsh interface ip set address name=&quot;local&quot; gateway=%GW222% gwmetric=0

@%PING%
@IF ERRORLEVEL 1 GOTO route2
@IF ERRORLEVEL 0 GOTO alive

:route2
@%GATEWAY102%
@ECHO &quot;Change route on %GW102% gateway at %DATE%%TIME%&quot; &gt;&gt; C:\inet.log
@%PING%
@IF ERRORLEVEL 1 GOTO route3
@IF ERRORLEVEL 0 GOTO alive
@GOTO end

:route3
@%GATEWAY222%
@ECHO &quot;Change route on %GW222% gateway at %DATE%%TIME%&quot; &gt;&gt; C:\inet.log
@%PING%
@IF ERRORLEVEL 1 GOTO route1
@IF ERRORLEVEL 0 GOTO alive
@GOTO end

:route1
@%GATEWAY101%
@ECHO &quot;Change route on %GW101% gateway at %DATE%%TIME%&quot; &gt;&gt; C:\inet.log
@%PING%
@IF ERRORLEVEL 1 GOTO end
@IF ERRORLEVEL 0 GOTO alive


:alive
@echo &quot;Inet work - %DATE%%TIME%&quot; &gt;&gt; C:\inet.log
@ECHO Alive
@GOTO end

:end
@ECHO Goodbye</code></pre></div><p>мне нужно добавить определение шлюза или маршрута по умолчанию. Посоветуйте плиз.</p>]]></description>
			<author><![CDATA[null@example.com (Valera)]]></author>
			<pubDate>Thu, 09 Feb 2012 14:33:48 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=56601#p56601</guid>
		</item>
	</channel>
</rss>
