Monday, April 19, 2010

Wake On LAN

General

How can I start a computer over the network?

There are two different procedures, depending on whether the target computer is in standby/sleep/suspend mode or whether it is actually powered down in hibernate mode or entirely off.

Note that you cannot wake a computer that is powered down over a WLAN connection. Only cable connections will do.

Waking from suspend mode

  1. On the target computer in Device Manager or in the network settings select the network card.
  2. Click on: Properties
  3. Click on the configure button of the network card.
  4. Select the tab: Power management
  5. Set a check mark at: Allow this device to bring the computer out of standby
  6. Click on: OK
  7. Continue to close all property pages.

Now your computer should wake up from standby whenever the network card is accessed by any other computer. If it doesn't, check any relevant BIOS settings, but usually there aren't any.

A frequent problem is that the computer is woken up by all and sundry network traffic, hence it may be better to send the computer to hibernate mode or shut it down and off altogether and use the following method.

Wake On LAN from hibernate or off mode

One way to do this is the following.

  1. Check whether the network adapter on the target computer supports Wake On LAN. Enable the function in the network adapter settings or in any special management program that came with it. If the network adapter is integrated on the motherboard, enable Wake On LAN in the motherboard BIOS.
  2. Download and install WakeOnLanGui from www.depicus.com.
  3. On the target computer, i.e. the one to be woken up, open a command line window and enter the command: ipconfig /all
  4. Note the physical address (sometimes called MAC = Media Access Control address) of your Ethernet adapter from the ipconfig output. Example: 00-E0-18-90-A5-44
  5. Run WakeOnLanGui on the computer from which you want to wake the other computer and type the physical address into the proper field in WakeOnLanGui. The other two fields are filled with 255.255.255.255, and the port is 7 or actually any other port. Port 9 is sometimes used.
  6. Shut down the computer to be waked.
  7. Test WakeOnLanGui.

If you need the opposite function as well, to shut down a computer remotely, have a look at:

http://www.microsoft.com/technet/sysinternals/utilities/PsShutdown.mspx

This program, PsShutdown, is a member of Sysinternals' PsTools group of freeware utilities.

To shut down and power down a remote computer named "computername", enter the command:

psshutdown -k -f -t 00 \\computername

-k indicates shutdown and powerdown, -f means force all running programs to close without asking, and -t 00 means don't wait (wait zero seconds) until shutting down the computer named computername. (Don't miss the required space between -t and 00.) This utility can do several other things as well, like sending the target computer into hibernate mode or rebooting it.

Wake On LAN over the Internet

One example of how to wake up a home or office computer across the Internet is the following.

Assume a home network with a WAN router, in this case a DrayTek Vigor 2500We with firmware version 2.54. The main problem is that you cannot use any of the usual methods to address the target computer. Since it is off, it has no IP address. False advice is widespread, because people keep forgetting this simple fact.

The router has to send a special broadcast packet into the Local Area Network, using the MAC (Media Access Control) address, rather than the IP address. With some routers you may be able to achieve this by sending a Wake-On-LAN packet to the router and forward the port to an internal broadcast address, for example: 192.168.0.255

With most routers, however, this still does not work. You have to rely on the router to have the special ability to forward or send a Wake-On-LAN broadcast packet. In the case of the DrayTek router this can only be achieved through the telnet interface, but unfortunately not yet through the Web interface. An example for the telnet command for this DrayTek router is:

wol up 00E01890A545

Of course you have to replace the hex number with the MAC address of your target computer, and for this particular router you cannot intersperse hyphens as usual. The router needs the address in the direct short hexadecimal format. Check your router's manual or help system for its specifics.


Wake On Lan Command Line

Wake on Lan Command Line

http://www.depicus.com/wake-on-lan/wake-on-lan-cmd.aspx

The command line tool wolcmd is run from a dos prompt. The syntax is as follows:

wolcmd [mac address] [ip address] [subnet mask] [port number]

you can also do a local broadcast if you are running on an internal network thus

wolcmd [macaddress] 255.255.255.255 255.255.255.255

where mac address is the unique address of the network card. To find the mac address of a card you can either open the computer and read the address on the sticker on the card or much easier is, if you are using TCP/IP, ping the machine from a dos prompt (ping [machine name or ip number] i.e. ping delphi or ping 10.43.43.43) then issue an arp command (arp -a) which will list the ip number and physical address of the card.

If the port number is not specified it will default to port 7

Running from a batch file

Simply add multiple entries thus:

wolcmd 009027a324fe 195.188.159.20 255.255.255.0 8900
wolcmd 009024a731da 212.86.64.31 255.255.255.0 8900

To run the batch file, say half an hour before everybody gets into work, use the AT command on a Windows NT computer.

The AT command schedules commands and programs to run on a computer at a specified time and date. The Schedule service must be running to use the AT command. The syntax is as follows:

AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]
AT [\\computername] time [/INTERACTIVE]
[ /EVERY:date[,...] | /NEXT:date[,...]] "command"


\\computername Specifies a remote computer. Commands are scheduled on local computer if this parameter is omitted.
id Is an identification number assigned to a scheduled command.
/delete Cancels a scheduled command. If id is omitted, all the scheduled commands on the computer are cancelled.
/yes Used with cancel all jobs command when no further confirmation is desired.
time Specifies the time when command is to run.
/interactive Allows the job to interact with the desktop of the use who is logged on at the time the job runs.
/every:date[,...] Runs the command on each specified day(s) of the week month. If date is omitted, the current day of the month is assumed.
/next:date[,...] Runs the specified command on the next occurrence of the day (for example, next Thursday). If date is omitted, current day of the month is assumed.
"command" Is the Windows NT command, or batch program to be run.


Example

wolcmd 00:1D:7D:22:DC:F0 192.168.1.86 255.255.255.128

wolcmd 001D7D22DCF0 192.168.1.86 255.255.255.128