WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Networks - Servers
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Wake up Machine on LAN

Keywords:  Wake on Lan WOL wake up machine LAN

Reference:
http://www.codeproject.com/useritems/WOL.asp

http://www.answers.com/topic/wake-on-lan

Wake On Lan some times uses port 0 and port 7, but now it seems everything is moving to port 9.

#DefineFunction Hex2Dec(hex)
   str="0123456789ABCDEF"
   hex=StrTrim(StrUpper(hex))
   hexlen=StrLen(hex)
   dec=0
   For x=1 To hexlen
       dec=(dec*16) + StrIndex(str,StrSub(hex,x,1),0,@FWDSCAN) -1
   Next
   Return(dec)
#EndFunction

BCastAddr="255.255.255.255"      ; Set network broacast address here
MacAddress="00:11:22:CC:DD:EE" ; Set MAC address of machine to wake up here
RemotePort = 9 ; Wake On Lan port (some times uses port 0 and port 7)

;--------------------------
bbpacket=BinaryAlloc( (6*16) + 6)
BinaryOleType(bbpacket,103,0,0,0)

BinaryPoke(bbpacket,0,255)
BinaryPoke(bbpacket,1,255)
BinaryPoke(bbpacket,2,255)
BinaryPoke(bbpacket,3,255)
BinaryPoke(bbpacket,4,255)
BinaryPoke(bbpacket,5,255)

For yy=0 To 15
   For xx=1 To 6
      mm=ItemExtract(xx,MacAddress,":")
      mm=Hex2Dec(mm)
      BinaryPoke(bbpacket,5+xx+(yy*6),mm)
   Next
Next

;The WinSock OCX has a distribution problem in that
;it sometimes is not installed properly.  This is
;reported to fix it...
If RegExistKey(@REGCLASSES,"Licenses\2c49f800-c2dd-11cf-9ad6-0080c7e7b78d") == @FALSE
 ErrorMode(@OFF)
 flag=RegSetValue(@REGCLASSES,"Licenses\2c49f800-c2dd-11cf-9ad6-0080c7e7b78d","mlrljgrlhltlngjlthrligklpkrhllglqlrk")
 ErrorMode(@CANCEL)
 If flag==0
    Message("Error","Admin access required to set registry key.")
    Exit
 EndIf
EndIf

objSocket = ObjectOpen("MSWinsock.Winsock")
objSocket.Protocol = 1     ;UDP
objSocket.RemotePort = 9
objSocket.RemoteHost = BCastAddr
objSocket.SendData(bbpacket)
ObjectClose(objSocket)
BinaryFree(bbpacket)

Message("All","Doned")
Exit

Article ID:   W14632
Filename:   Wake up Machine on LAN.txt
File Created: 2008:03:24:08:47:38
Last Updated: 2008:03:24:08:47:38