Skip navigation.

Python - Get Last Windows Reboot Date/Time

Python - Get Last Windows Reboot Date/Time

This script will output the last reboot date/time for a local Windows machine:

 import re from subprocess import Popen, PIPE p = Popen('net
statistics workstation', stdout=PIPE) m = re.search('(\d+/\d+/\d{4}.*[A|P]M)', p.stdout.read())
if m: print 'Last Reboot: %s' % (m.group(1)) 

Output:

>> Last Reboot: 3/1/2008 1:51:41 PM





* updated the original script thanks to Ian's comment below