<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>憂藍夢境‧部落格 &#187; 自動連線</title>
	<atom:link href="http://blog.linym.net/archives/tag/%e8%87%aa%e5%8b%95%e9%80%a3%e7%b7%9a/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.linym.net</link>
	<description>我的學習心得、筆記</description>
	<lastBuildDate>Thu, 10 Sep 2009 07:50:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Windows PPPoE 自動重撥 Script</title>
		<link>http://blog.linym.net/archives/522</link>
		<comments>http://blog.linym.net/archives/522#comments</comments>
		<pubDate>Sat, 25 Jul 2009 10:51:09 +0000</pubDate>
		<dc:creator>lym520</dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[程式筆記]]></category>
		<category><![CDATA[系統筆記]]></category>
		<category><![CDATA[adsl]]></category>
		<category><![CDATA[pppoe]]></category>
		<category><![CDATA[WSH]]></category>
		<category><![CDATA[自動連線]]></category>

		<guid isPermaLink="false">http://blog.linym.net/?p=522</guid>
		<description><![CDATA[隨著 ADSL 及經濟型光纖網路的普及，有許多人都會在自家架設 server 主機，但如果沒有用分享器而是直接透過 PPPoE 撥接上網的，就很怕網路突然斷線(如忘記繳錢被停掉)，雖然說 Windows 內建的連線程式有一個「斷線後重新撥號」的選項，但其實並不好用。比較保險的作法是系統定期檢查對外連線的狀況(ping)，一旦發現斷線就自動重新連線。
在網路上可以找到很多這種作法的 Linux 版本，如「Debian Linux: ADSL PPPoE 自動重撥 Script」，但相對 Windows 的討論卻很少，所以就自己寫了一個重撥的 WSH(Windows Script Host)，搭配工作排程就可以達到目的。
※ 本方法適用於 XP 以後之 Windows。
Step 1：將下列程式存為 repppoe.vbs，修改連線資訊並放置在安全的地方


DIALNAME = &#34;寬頻連線&#34;              &#039;連線名稱
DIALUSER = &#34;12345678@ip.hinet.net&#34; &#039;連線帳號
DIALPASS = &#34;xxxxxxxx&#34;        [...]]]></description>
			<content:encoded><![CDATA[<p>隨著 ADSL 及經濟型光纖網路的普及，有許多人都會在自家架設 server 主機，但如果沒有用分享器而是直接透過 PPPoE 撥接上網的，就很怕網路突然斷線(如忘記繳錢被停掉)，雖然說 Windows 內建的連線程式有一個「斷線後重新撥號」的選項，但其實並不好用。比較保險的作法是系統定期檢查對外連線的狀況(ping)，一旦發現斷線就自動重新連線。</p>
<p>在網路上可以找到很多這種作法的 Linux 版本，如「<a href="http://plog.longwin.com.tw/programming/2007/08/24/adsl_repppoe_script_2007" target="_blank">Debian Linux: ADSL PPPoE 自動重撥 Script</a>」，但相對 Windows 的討論卻很少，所以就自己寫了一個重撥的 WSH(Windows Script Host)，搭配工作排程就可以達到目的。<br />
<span style="color:red">※ 本方法適用於 XP 以後之 Windows。</span></p>
<p><strong>Step 1：將下列程式存為 <span style="color:blue">repppoe.vbs</span>，修改連線資訊並放置在安全的地方</strong></p>
<pre title="code" class="vb">

DIALNAME = &quot;寬頻連線&quot;              &#039;連線名稱
DIALUSER = &quot;12345678@ip.hinet.net&quot; &#039;連線帳號
DIALPASS = &quot;xxxxxxxx&quot;              &#039;連線密碼

Set WshShell = CreateObject(&quot;WScript.Shell&quot;)
RetCode = WshShell.Run(&quot;ping www.hinet.net&quot;, 0, true)
If RetCode &lt;&gt; 0 Then
	WshShell.Run &quot;rasdial &quot; &amp; DIALNAME &amp; &quot; /DISCONNECT&quot;, 0, true
	WScript.Sleep(3000)
	WshShell.Run &quot;rasdial &quot; &amp; DIALNAME &amp; &quot; &quot; &amp; DIALUSER &amp; &quot; &quot; &amp; DIALPASS, 0
End If
</pre>
<p><strong>Step 2：設定 Windows 工作排程。</strong>(控制台->排定的工作->新增排定的工作)</p>
<p><a href="http://blog.linym.net/wp-content/uploads/2009/07/1.JPG"><img src="http://blog.linym.net/wp-content/uploads/2009/07/1.JPG" alt="1" title="1" width="522" height="326" class="alignnone size-full wp-image-535" /></a><br />
‧選擇步驟 1 的 repppoe.vbs 檔案</p>
<p><a href="http://blog.linym.net/wp-content/uploads/2009/07/2.JPG"><img src="http://blog.linym.net/wp-content/uploads/2009/07/2.JPG" alt="2" title="2" width="522" height="326" class="alignnone size-full wp-image-538" /></a></p>
<p><a href="http://blog.linym.net/wp-content/uploads/2009/07/3.JPG"><img src="http://blog.linym.net/wp-content/uploads/2009/07/3.JPG" alt="3" title="3" width="522" height="326" class="alignnone size-full wp-image-539" /></a></p>
<p><a href="http://blog.linym.net/wp-content/uploads/2009/07/4.JPG"><img src="http://blog.linym.net/wp-content/uploads/2009/07/4.JPG" alt="4" title="4" width="522" height="326" class="alignnone size-full wp-image-541" /></a><br />
‧輸入具有 Administrator 權限的使用者及密碼</p>
<p><a href="http://blog.linym.net/wp-content/uploads/2009/07/5.JPG"><img src="http://blog.linym.net/wp-content/uploads/2009/07/5.JPG" alt="5" title="5" width="522" height="326" class="alignnone size-full wp-image-542" /></a></p>
<p><a href="http://blog.linym.net/wp-content/uploads/2009/07/6.JPG"><img src="http://blog.linym.net/wp-content/uploads/2009/07/6.JPG" alt="6" title="6" width="406" height="416" class="alignnone size-full wp-image-543" /></a></p>
<p><a href="http://blog.linym.net/wp-content/uploads/2009/07/7.JPG"><img src="http://blog.linym.net/wp-content/uploads/2009/07/7.JPG" alt="7" title="7" width="368" height="252" class="alignnone size-full wp-image-544" /></a><br />
‧表示每 30 分鐘檢查一次連線狀況，可依需求修改，然後收工。</p>
<p>※ 備註：<br />
之所以選擇 ping www.hinet.net 而不用 IP 是因為經實驗結果，若網卡有設定 Default gateway，則可能會因為 gateway response 影響連線判斷。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.linym.net/archives/522/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
