WakeOnLan is a very small program made with Delphi which sends a magic broadcast packet to turn on a certain computer if it has WOL enabled. It was my first program ever which really got into packets and network interaction. I fiddled a lot with wireshark before I got it working properly. The usage of this program is very simple, you have to fill in the mac address of the network adapter of the computer you want to wake up, mostly you have to send the packet to UDP port 9 but sometimes it also has to be set to 7 or another port.

The magic packet for WOL is a broadcast frame containing 6 bytes of all 255 (FF FF FF FF FF FF in hexadecimal), followed by sixteen repetitions of the target computer's 48-bit MAC address. (Total of 102 bytes)

On request by /u/hippox89, I created a second version called WakeOnLanTimer which can resend the magic packet for a chosen interval. Source and executable available at the bottom.

The program now also saves the filled in settings in an ini file, stored in the application directory.

WakeOnLan consists of one main function:

procedure TfrmMain.btnWOLClick(Sender: TObject); var i: Integer; strMac: string; Buffer: TBytes; UDPClient: TIdUDPClient; begin //Trim Mac address from - and : and . strMac := ''; for i := 1 to Length(edMac.Text) do begin if not((edMac.Text[i] = ':') or (edMac.Text[i] = '-') or (edMac.Text[i] = '.')) then strMac := strMac + edMac.Text[i]; end; //Create buffer SetLength(Buffer,102); //Fill first 6 bytes with FF (FF= Ord(255)) for i := 0 to 5 do Buffer[i] := Ord(255); //Fill the rest with 16 times the MAC address for i := 1 to 16 do begin Buffer[i*6] := StrToInt('$'+strMac[1]+strMac[2]); Buffer[i*6+1] := StrToInt('$'+strMac[3]+strMac[4]); Buffer[i*6+2] := StrToInt('$'+strMac[5]+strMac[6]); Buffer[i*6+3] := StrToInt('$'+strMac[7]+strMac[8]); Buffer[i*6+4] := StrToInt('$'+strMac[9]+strMac[10]); Buffer[i*6+5] := StrToInt('$'+strMac[11]+strMac[12]); end; //UDP Broadcast UDPClient := TIdUDPClient.Create(nil); UDPClient.BroadcastEnabled := True; UDPClient.SendBuffer('255.255.255.255',strtoint(edPort.Text),Buffer); UDPClient.Free; end;

Download:

WOL Source (20,5 KB)

WOL Executable (648 KB)



WOLT Source (20,4 KB)

WOLT Executable (666 KB)