this is my WOL routine (from a previous thread)

WOL.exe is located in %windir%
WOL requires the MAC address of the target PC

The only way of getting the MAC, is either have each PC log it to a central location or collect it from the DHCP server.

I use MS DHCP server and dhcpcmd.exe to retrieve the MAC address and populate an array (compname,macaddr)

code:
	$server = '192.168.1.2'

$command = 'cmd /c %windir%\dhcpcmd.exe '+ $server +' getsuperscopetable | find "Subnet address"'
$superscope = WSHPipe($command,1)

for each $scope in $superscope
$subnet = trim(split($scope,'=')[1])
$command = 'cmd /c %windir%\dhcpcmd.exe '+ $server +' enumclients ' + $subnet+' -h'
$output = WSHPipe($command,1)
$x = 0
For each $line in $output
if val(left($line,1))
$arr_IPaddr[$x] = trim(substr($line,4,15))
$arr_Computer[$x] = split(trim(substr($line,21,16)),'.')[0]
$arr_MACaddr[$x] = trim(substr($line,38,17))
$x = $x +1
redim preserve $arr_IPaddr[$x]
redim preserve $arr_Computer[$x]
redim preserve $arr_MACaddr[$x]
endif
next
next
for each $item in $ListViewEx1.items
if left($item.SubItems(3).Text,6) = 'Offlin' and $item.subitems(1).text = '¤'
$Computer = $item.SubItems(2).Text
$pos = ascan($arr_Computer,$computer)
if $pos +1
$mac = $arr_MACaddr[$pos]
Status("Sending WOL to $computer")
shell 'cmd /c %windir%\wol.exe ' + $mac +' > nul'
else
Status("MAC Addr Not available for $computer")
endif
endif
next
sleep 15
endfunction

This is just the code from a current project (Remote Execution Manager), but if you try, you can figure out the details
_________________________
How to ask questions the smart way <-----------> Before you ask