Techibee.com

Say hello to uptime2.exe: Alternative for uptime.exe

[ Now-a-days many people are capable of writing and using Powershell codes. Given this fact, the uptime2.exe is removed. There is a better PowerShell alternative for this at https://techibee.com/powershell/get-computer-uptime-using-powershell/659]

Ever since I started using Windows 7/Windows 2008 R2 Operating System this problem is there. Uptime.exe utility crashes with error message “Calculates system uptime and availability has stopped working” when I use with “/S” option. The /S option of uptime.exe gives the historical information about computer startup and shutdown times. This information is very useful to understand how many times a computer rebooted.

Since this built-in tool is not working, I explored the ways to get the last X reboots information from a PC using alternate methods. In early stages, I assumed this historical reboot information is stored in some WMI or file system so that I can easily query. After long wait, I came to know that it is actually based on event logs. All we need to do is parse event logs and get the historical startup and shutdown times of the computer.

After knowing the source of information, my interest towards building my own solution to get the last X reboot times information has increased. I did it in powershell and used it whenever I needed. However, I felt having a powershell function may be easy way for folks like me who want to get their hand dirty with powershell. Other system administrators really won’t like it as they need to open powershell, look for command and type it there to get the required output. For various reasons, powershell console a slow staring application. Also it is difficult to remember the function name(or equivalent code) to get the reboots information. Given these reasons, I wanted to build a quick alternative, and that is when Uptime2.exe born.

So I developed a C# console application which mimics the functionality of uptime.exe tool in windows and returns the output we need. “C# application? Hey Poweshell guy, what happened to you?” – Nothing really but somehow I liked the language and started exploring more. Still PS is my best choice for quick and dirty tasks. In fact PS made me my dive into c# very easy and quick. Keeping my happening aside let me talk more about the tool I developed.

The uptime2.exe is a C# console application. It takes two parameters mainly, /Computername and /S. The ComputerName parameter is for querying the information from remote computer and “/S” option works the same way as in uptime.exe – i.e generates historical reboot information. When none of these parameters are specified, the tool just returns the uptime of local computer.

I have too many plans for enhancing this tool. But don’t have enough time in hand at this moment. This is the best shape I can give my thoughts in 5 hours(yes, it took me that much). However, when I ever I find time, I will try to improve it to return more information like Timezone of remote computer(I think no tool does this right now), display last boot time, etc (if you think a feature is worth adding here, please mention in comments section).

I briefly tested this tool in my lab and is giving the desired results. I took care of error handling to the possible extent I can. If you notice any errors, please report to me.

Download:

You can download the tool from here (not available for download anymore) and use it for your requirements. It is FREE. I will share the code as well once my GIT repository is ready for usage.

[Updates]

08/16/2012 : Initial release

08/18/2012: Fixed a bug with time conversion.(Thanks to Srinivas for reporting it)

Below are the a few use cases:

 Disclaimer:

Well, I felt I should add a disclaimer for this utility. Please test the tool in test environment before trying in production. I AM NO WAY RESPONSIBLE FOR ANY KIND OF DAMAGE MADE BY THIS TOOL. USE AT YOUR OWN RISK.

Happy learning and let me know your feedback.

 

 

Exit mobile version