Wake on LAN

myname

New member
Hi!

I tried to wake up a PC following this suggestion: Macrodroid WoL

I entered the following data for an UDP block:
Destination: 192.168.178.250
Port: 7
Message: 0xffffffffffff[v=MAC][v=MAC][v=MAC][v=MAC][v=MAC][v=MAC][v=MAC][v=MAC][v=MAC][v=MAC][v=MAC][v=MAC][v=MAC][v=MAC][v=MAC][v=MAC]

The global variable MAC is also set to the MAC address of the Server I want to wake up.

Macrodroid shows the following error message (translated) when I try to test the UDP command:


UDP command failed
Invalid message format

I also copied the commands from the mentioned thread but it still doesn't work.

Any suggestions?

Best regards.
 
Last edited:

tanutanu

Well-known member
First, make sure your PC was enabled WoL feature, then check the MAC variable truly contains the target mac address.
If both are ok, try UDP port 9 and/or checking broadcast filter of your network router or switch.
 
Last edited:

myname

New member
@tanutanu I figured out the solution:
To wake up a device with Wake on Lan do the following:
1. Convert your MAC address to base 16 integer: Convert MAC
Example: AC:16:2D:02:C8:19 --> 0xac162d02c819 --> ac162d02c819 (remove the leading 0x)
2. Create a new UDP block with
target: broadcast address or target IP address. Target IP address didn't work with my router though.
Port: 80 (some suggest Port 7 or 9 for Wake on LAN)
message:
  • 0x to signal hex values
  • ffffffffffffffff (16 times f)
  • ac162d02c81 (16 times MAC address as base 16 integer, I wont repeat it 16 times here)
The message is a single string without any separators/spaces, for example:

0xffffffffffffffffac162d02c81ac162d02c81ac162d02c81ac162d02c81ac162d02c81ac162d02c81ac162d02c81ac162d02c81ac162d02c81ac162d02c81ac162d02c81ac162d02c81ac162d02c81ac162d02c81ac162d02c81ac162d02c81

Good luck.
 
Last edited:

tanutanu

Well-known member
ah, yep, the magic packet should be HEX, 102 bytes length:) String is ascii code byte(equal to utf8 alphanumeric) stream.
 

limbo

New member
I have created a VBS script to automatically generate the magic packet.
Running the script will prompt you for the MAC address and then it will generate a text file C:\MAC\magic_packet.txt

Form that point you sould just cretae a macro and add the generated ytext under the UDP command.

Code follows.

save it as a *.VBS file and run it.
Enjoy

C#:
' Function to convert MAC address to base 16 integer
Function ConvertMacToHex(macAddress)
    ConvertMacToHex = Replace(macAddress, ":", "")
End Function

' Function to create the Wake on LAN magic packet
Function CreateMagicPacket(macHex)
    Dim i
    Dim magicPacket

    ' Start with 6 pairs of FF
    magicPacket = "FFFFFFFFFFFF"

    ' Append the MAC address 16 times
    For i = 1 To 16
        magicPacket = magicPacket & macHex
    Next

    CreateMagicPacket = magicPacket
End Function

' Main script
Sub Main()
    Dim macAddress, macHex, magicPacket, outputFile
    macAddress = InputBox("Enter the MAC address (format: XX:XX:XX:XX:XX:XX):", "MAC Address Input")

    If macAddress = "" Then
        MsgBox "No MAC address entered. Exiting.", vbExclamation
        Exit Sub
    End If

    ' Convert MAC address to hexadecimal string
    macHex = ConvertMacToHex(macAddress)

    ' Create the magic packet
    magicPacket = CreateMagicPacket(macHex)

    ' Output the magic packet to a text file
    outputFile = "C:\MAC\magic_packet.txt"
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set file = fso.CreateTextFile(outputFile, True)
    file.WriteLine "0x" & magicPacket
    file.Close

    MsgBox "Magic packet saved to " & outputFile, vbInformation
End Sub

' Execute the main script
Main
 
Top