<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How Can I Determine the Uptime for a Server?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2005/08/02/how-can-i-determine-the-uptime-for-a-server.aspx</link><description>Hey, Scripting Guy! How can I determine the uptime for a server? -- LF 
 Hey, LF. This is an easy one. After all, we’re assuming you’re talking about a Windows server, and Windows servers never go down, right? Therefore, the uptime must be forever. Problem</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: How Can I Determine the Uptime for a Server?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2005/08/02/how-can-i-determine-the-uptime-for-a-server.aspx#3527801</link><pubDate>Sun, 21 Oct 2012 14:52:22 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3527801</guid><dc:creator>Toby S</dc:creator><description>&lt;p&gt;Thank. &amp;nbsp;Your post was very helpful.&lt;/p&gt;
&lt;p&gt;I think a better way to deal with WMI dates is to use the WMI class &amp;quot;WbemScripting.SWbemDateTime&amp;quot;. &amp;nbsp;You could write:&lt;/p&gt;
&lt;p&gt;Function WMIDateStringToDate(dtmBootup)&lt;/p&gt;
&lt;p&gt; &amp;nbsp;Set objWMIDate = CreateObject(&amp;quot;WbemScripting.SWbemDateTime&amp;quot;)&lt;/p&gt;
&lt;p&gt; &amp;nbsp;objWMIDate.Value = dtmBootup&lt;/p&gt;
&lt;p&gt; &amp;nbsp;WMIDateStringToDate = objWMIDate.GetVarDate(True)&lt;/p&gt;
&lt;p&gt;End Function&lt;/p&gt;
&lt;p&gt;The True parameter for .GetVarDate(True) means treat it as a local time (instead of UTC). &amp;nbsp;I&amp;#39;m not certain if this works for Windows 2000, but that OS is now defunct anyway.&lt;/p&gt;
&lt;p&gt;And querying Win32_OperatingSystem is much faster than Win32_PerfFormattedData_PerfOS_System - at least on Windows 7.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3527801" width="1" height="1"&gt;</description></item><item><title>re: How Can I Determine the Uptime for a Server?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2005/08/02/how-can-i-determine-the-uptime-for-a-server.aspx#3389932</link><pubDate>Thu, 24 Feb 2011 18:12:37 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3389932</guid><dc:creator>Wil Welsh</dc:creator><description>&lt;p&gt;The value of LastBootUpTime is blank on some machines. &amp;nbsp; What gives?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3389932" width="1" height="1"&gt;</description></item><item><title>re: How Can I Determine the Uptime for a Server?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2005/08/02/how-can-i-determine-the-uptime-for-a-server.aspx#3349823</link><pubDate>Thu, 12 Aug 2010 20:25:34 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3349823</guid><dc:creator>Malcolm.</dc:creator><description>&lt;p&gt;Eric ... system event log; look for the appropriate events and use their times for the shutdown and startup times [a quick look at my log reveals you probably want source EventLog, Event ID 6009 for system startup and Event ID 6006 for shutdown], the rest is just adding up.&lt;/p&gt;
&lt;p&gt;Of course, you can also assume an event ID 6009 which is NOT preceded by an event ID 6006 is an abnormal shutdown. This is just a simple first pass at answering your question and the method will probably need further tweaking ;)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3349823" width="1" height="1"&gt;</description></item><item><title>re: How Can I Determine the Uptime for a Server?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2005/08/02/how-can-i-determine-the-uptime-for-a-server.aspx#3349821</link><pubDate>Thu, 12 Aug 2010 20:18:25 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3349821</guid><dc:creator>Malcolm</dc:creator><description>&lt;p&gt;Your WMIDateStringToDate, while it may work fine for those in the US, could do with a little tweak.&lt;/p&gt;
&lt;p&gt;European users tend to use dd/mm/yyyy for dates, and things become even more confusing when you have (like I do) a system in the UK which is installed with English (US) as the base language but the account has English (UK) set; unless that&amp;#39;s set you end up with some accounts with mm/dd/yyyy for dates and some with dd/mm/yyyy and the conversions become unreliable.&lt;/p&gt;
&lt;p&gt;But! there is an easy way out of this; CDate will accept date-times in the form YYYY-MM-DD HH:MM:SS; so if you adjust the function a little you get accurate results no matter which way round the local date format is:&lt;/p&gt;
&lt;p&gt;Function WMIDateStringToDate(dtmBootup)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;WMIDateStringToDate = CDate(Left(dtmBootup, 4) &amp;amp; &amp;quot;-&amp;quot; &amp;amp; _&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Mid(dtmBootup, 5, 2) &amp;amp; &amp;quot;-&amp;quot; &amp;amp; Mid(dtmBootup, 7, 2) &amp;amp; _&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;quot; &amp;quot; &amp;amp; Mid (dtmBootup, 9, 2) &amp;amp; &amp;quot;:&amp;quot; &amp;amp; _&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Mid(dtmBootup, 11, 2) &amp;amp; &amp;quot;:&amp;quot; &amp;amp; Mid(dtmBootup,13, 2))&lt;/p&gt;
&lt;p&gt;End Function&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3349821" width="1" height="1"&gt;</description></item><item><title>re: How Can I Determine the Uptime for a Server?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2005/08/02/how-can-i-determine-the-uptime-for-a-server.aspx#3339744</link><pubDate>Tue, 22 Jun 2010 16:58:10 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3339744</guid><dc:creator>eric young</dc:creator><description>&lt;p&gt;Could you tell me how to get the system uptime in last 24 hours? &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3339744" width="1" height="1"&gt;</description></item></channel></rss>