<?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>nPath Ltd. &#187; scripting</title>
	<atom:link href="http://www.npathweb.com/tag/scripting/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.npathweb.com</link>
	<description>Web Development Blog</description>
	<lastBuildDate>Tue, 10 Jan 2012 02:22:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Automatically reboot an unresponsive Windows Server</title>
		<link>http://www.npathweb.com/2009/02/05/automatically-reboot-an-unresponsive-windows-server/</link>
		<comments>http://www.npathweb.com/2009/02/05/automatically-reboot-an-unresponsive-windows-server/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 16:54:14 +0000</pubDate>
		<dc:creator>B.Harding</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[Windows Automation]]></category>
		<category><![CDATA[Windows Server]]></category>

		<guid isPermaLink="false">http://www.npathweb.com/blog/?p=11</guid>
		<description><![CDATA[My servers are leased so if anything goes wrong and a reboot is needed I have to wait for my provider to preform it. In this post we will create a vb Script that pings an IP address and reboots if it can&#8217;t see it. We will simply run it on a timer using the [...]]]></description>
			<content:encoded><![CDATA[<p>My servers are leased so if anything goes wrong and a reboot is needed I have to wait for my provider to preform it.</p>
<p>In this post we will create a vb Script that pings an IP address and reboots if it can&#8217;t see it. We will simply run it on a timer using the command scheduler.</p>
<p>Here is the script:</p>
<p>Option Explicit</p>
<p>dim strHost</p>
<p>&#8216;The ip address you want to monitor<br />
strHost=&#8221;111.222.333.444&#8243;</p>
<p>if Ping(strHost) = True then</p>
<p>&#8216;You can do stuff here if you want.</p>
<p>Else</p>
<p>&#8216;The next three lines reboot</p>
<p>dim objShell<br />
Set objShell = CreateObject(&#8220;WScript.Shell&#8221;)<br />
objShell.Run &#8220;shutdown /r /t 000&#8243;</p>
<p>end if</p>
<p>&#8216;the following is a subroutine called above</p>
<p>Function Ping(strHost)</p>
<p>dim objPing, objRetStatus</p>
<p>set objPing = GetObject(&#8220;winmgmts:{impersonationLevel=impersonate}&#8221;).ExecQuery(&#8220;select * from Win32_PingStatus where address = &#8216;&#8221; &amp; strHost &amp; &#8220;&#8216;&#8221;)</p>
<p>for each objRetStatus in objPing<br />
if IsNull(objRetStatus.StatusCode) or objRetStatus.StatusCode&lt;&gt;0 then</p>
<p>Ping = False</p>
<p>else<br />
Ping = True<br />
end if<br />
next<br />
End Function</p>
<p>Just save this to a vbs file and add</p>
<p>cscript c:\ping.vbs</p>
<p>to &#8220;Scheduled tasks&#8221; every 15 minutes.</p>
<p>&#8216;Till next time&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.npathweb.com/2009/02/05/automatically-reboot-an-unresponsive-windows-server/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

