Categories
BSOD Command Prompt cscript Linux systeminfo Windows 2008 Windows 7 Windows Vista WMI wmic

Find Last Reboot Time in Windows 7, Vista and Windows 2008

Have you ever wanted a quick and easy way to know how long your Windows 7 (or Vista or Windows 2008 server) system has been running?  When it was last restarted or rebooted?  There are a few easy ways this can be done, most from the Windows command line.  So open a Windows command prompt and choose the one that works best for you.  (Most of these commands work with Windows XP, Windows 2003, 2000, etc.  See notes below for specifics.)

  • This first way will display how long the network service has been running.  Generally this will be very close to the same amount of time (within a minute or two) as Windows has been running.  It won’t be accurate if you restart the network service.
    Note: I listed this first because it’s the one I usually use.

    From a command prompt window run the following (the ‘S’ in ‘Statistics’ must be capitalized):

net statistics workstation | find "Statistics"

You can shortcut it as well using:

net stats work | find "Stat"

Result:

Or ever shorter use either of the following:

net stats work
netstats work |more

  • This next method uses the command ‘systeminfo.’  Again from a command prompt run (make sure to capitalize ‘S’, ‘B’ and ‘T’:

systeminfo | find "System Boot Time"

Result:

You can use the following on XP, Windows 2003 and earlier (however this will give only the length of uptime and not the system boot time):

systeminfo | find "Up Time"

  • The third method uses WMI, more specifically wmic (Windows Management Instrumentation Command-line), but the output is a little cryptic:

wmic OS Get LastBootUpTime

Result: 20091220133343.981621-300, which can be intrepreted as year 2009, month 12, day 20, hour 13 (or 1:00 PM), minute 33, etc.  Note: be careful as this may be displayed as UTC time depending on your system – like with Amazon EC2 virtual servers for example.

  • You can always use the system event log (this only works on 2003/XP or older).  Of course, you could go to Control Panel and browse through the system event log, but let’s do it through the command line with:

cscript c:windowssystem32eventquery.vbs /fi "ID eq 6005" /l system

Over the years I have found system event log event 6005, “The Event log service was started.” to be the the most consistent entry after a computer restarts, even from a power outage, BSOD or other event.  This command will also give you a history of system startups listed in the System event log.

  • Finally, you can use this handy PowerShell script:
    Get-WmiObject Win32_NTLogEvent -filter "LogFile='System' and EventCode=6005" | Format-Table ComputerName, EventCode, Message, TimeWritten

Just like with anything there are many ways to skin this cat, so choose your favorite one (or two to double-check data) and go for it.

Categories
Apple Linux

Disable Unnecessary Services on Mac OS X

How to disable unnecessary services on Mac OS X based desktop / server / laptop.

Mac OS X uses the following directories to start various services:

  1. /System/Library/LaunchDaemons/ – System-wide daemons provided by Mac OS X
  2. /System/Library/LaunchAgents/ – Per-user agents provided by Mac OS X
  3. ~/Library/LaunchAgents/ – Per-user agents provided by the user
  4. /Library/LaunchAgents/ – Per-user agents provided by the administrator
  5. /Library/LaunchDaemons/ – System-wide daemons provided by the administrator.

launchd manages processes, both for the system as a whole and for individual users using .plist files. Open the terminal and type the following commands to view directory files:

cd /System/Library/LaunchDaemons/
ls -l
ls -l | less

OR

cd /System/Library/LaunchAgents/
ls -l
ls -l | less

Disable Unnecessary Services
Use the launchctl command as follows:

sudo launchctl unload -w /path/to/.plist/file
sudo launchctl unload -w /System/Library/LaunchDaemons/file.plist

In this example, use the following to disable the Bonjour service:

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponderHelper.plist

Categories
IIS 6 Linux SSL Windows 2003 Windows XP

Setup self-signed certificate on IIS 6


Create a self-signed SSL certificate with SelfSSL from the IIS 6.0 Resource Kit.

The IIS 6.0 Resource Kit contains a utility called SelfSSL.exe for quickly and easily creating and installing a self-signed certificate into IIS 6 for Windows 2003 or XP.

  • Download IIS 6.0 Resource Kit Tools
  • Install the resource kit
  • Go to Programs IIS Resources SelfSSL and select “SelfSSL”
  • Execute the following (modify for your environment):
    selfssl.exe /N:CN=www.powercram.com /K:1024 /V:180 /S:56792119 /P:443 /T

  • Go to https://localhost to test.

Explanation of selfssl.exe switches (used in command above):

  • /N:CN=www.powercram.com – common name of the certificate.
  • /K:1024 – key length.
  • /V:180 – number of days certificate is valid.
  • /S:56792119 – IIS site ID.  Default is 1 for “default site.”
  • /P:443 – SSL port.
  • /T – Adds the self-signed certificate to “Trusted Certificates” list.
Categories
Iperf iperf examples Linux SourceForge

Measure Network Throughput (Bandwidth) with Iperf

Iperf is a tool for measuring maximum TCP and UDP bandwidth performance. Iperf reports bandwidth, delay jitter, datagram loss.

Iperf allows the user to set various parameters that can be used for testing a network, or alternately for optimizing or tuning a network. Iperf has a client and server functionality, and can measure the throughput between the two ends, either unidirectonally or bi-directionally. It is open source software and runs on various platforms including Linux, Unix and Windows. It is supported by the National Laboratory for Applied Network Research.

When used for testing UDP capacity, Iperf allows the user to specify the datagram size and provides results for the datagram throughput and the packet loss.

When used for testing TCP capacity, Iperf measures the throughput of the payload. One thing to note is that Iperf uses 1024*1024 for megabytes and 1000*1000 for megabits. There is a Graphical user interface (GUI) front end available called jperf.

Typical Iperf output contains a timestamped report of the amount of data transferred and the throughput measured.

Iperf is significant as it is a standardized tool that can be run over any network and output standardized performance measurements. Thus it can be used for comparison of wired and wireless networking equipment and technologies in an unbiased way. As it is open source, the measurement methodology can be scrutinized by users.

See also Use Iperf to Measure Network Throughput (Bandwidth) for examples and details on using Iperf.

Download Iperf and get more information from SourceForge.