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
Copyright © 2006-2008 Corey Goldberg
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.