13 Replies - 4625 Views - Last Post: 14 August 2013 - 09:53 AM Rate Topic: -----

#1 kyle_denney   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 171
  • Joined: 10-August 12

Wake On Lan Code Not Working - Packet Not Waking Up?

Posted 09 August 2013 - 09:04 AM

Hello,

I developed this code and cannot see why it is not working - I believe it did at one time but want someone to comb through it to make sure I am inputing the right information for the magic packet builder portion. Thanks!

 Public Sub wol()
 
        Try
            'CHECK IF DIGIT COUNT IS PROPER AMOUNT - IF SO THEN RUN WOL AFTER CHECKING FOR ENTER KEY PRESS
 
            'WAKE THE COMPUTER UP
            Dim Client As New UdpClient
            Dim counter As Integer = 0
            Dim wolpacketArray(101) As Byte '101 is the length of bytes in the array for 15 '192/2 = why 569? it was wolpacketarray(569) '192 is the number of bytes in the sequence (15 loops with 12 number/letters in a mac = 180 plus the ff sequence is another 12)
            Dim Pos As Integer = 0
 
            Client.Connect(IPAddress.Broadcast, 12287) 'ipaddress.broadcast = 255.255.255.255, then the port number to broadcast over
            Dim s As String
            For i As Integer = 0 To 5
                wolpacketArray(counter) = 255 'THIS IS THE HEX FOR 'FF'
                'ADD THAT TO THE BIT SEQUENCE
                s = BitConverter.ToString(wolpacketArray)
                counter += 1
            Next
 
            'TAKE THE COLONS OUT OF THE MAC ADDRESS FOR EASIER CONVERSION
            Dim colonLessMacAddress As String
            If mtxtMACAddress.Text <> String.Empty Then
                colonLessMacAddress = Replace(mtxtMACAddress.Text, ":", "")
            Else
                colonLessMacAddress = Replace(frmSnapshotView.cboMACAddress.Text, ":", "")
            End If
            'LOOP FOR STRINGING TOGETHER THE MAC ADDRESS
            For i As Integer = 0 To 15
                Pos = 0
                'since your mac is six bytes loop through the byte sequence and get the correpsonding 2 letter character sequnce
                'and add that to the bit sequence 16 times
                For n As Integer = 0 To 5
                    wolpacketArray(counter) = Byte.Parse(colonLessMacAddress.Substring(Pos, 2), Globalization.NumberStyles.HexNumber)
                    Pos += 2
                    counter += 1
                    s = BitConverter.ToString(wolpacketArray)
                Next
            Next
            MsgBox(s.ToString)
            s = BitConverter.ToString(wolpacketArray)
 
            'SEND THE PACKET TO THE MAC ADDRESS ON THE NETWORK AT THE SPECIFIED PORT
            Client.Send(wolpacketArray, wolpacketArray.Length) '569)
 
            If My.Computer.Network.Ping(cboComputerName.Text) Then
                frmMessagebox.MessageDialog("Wake On Lan Succeeded", "WOL Success", 2, 2)
                frmMessagebox.ShowDialog()
            End If
 
        Catch ex As Exception
            MsgBox(ex.Message & ex.StackTrace)
            frmMessagebox.MessageDialog("Unable To Wake On Lan" & vbCrLf & "Ensure Wake On Lan Is Enabled", "Unable To Wake On Lan", 0, 0)
            frmMessagebox.ShowDialog()
            Exit Sub
 
        End Try
 
    End Sub





Is This A Good Question/Topic? 0
  • +

Replies To: Wake On Lan Code Not Working - Packet Not Waking Up?

#2 ybadragon   User is offline

  • Home Owner
  • member icon

Reputation: 571
  • View blog
  • Posts: 2,647
  • Joined: 11-May 12

Re: Wake On Lan Code Not Working - Packet Not Waking Up?

Posted 09 August 2013 - 09:12 AM

we need more information. Are you getting an error? We need to know what error you are getting. Is it not executing the way you think it should? How is it supposed to execute and how is it executing? Did you step through your code? Put break-point before the error occurs and step through it.
Was This Post Helpful? 0
  • +
  • -

#3 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15356
  • View blog
  • Posts: 61,567
  • Joined: 12-June 08

Re: Wake On Lan Code Not Working - Packet Not Waking Up?

Posted 09 August 2013 - 09:14 AM

Quote

I believe it did at one time but want someone to comb through it to make sure I am inputing the right information

... you believed this worked at once point? That seems a bit, hazy.

Are you sure the target machine has 'wake on lan' setup?
Was This Post Helpful? 0
  • +
  • -

#4 kyle_denney   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 171
  • Joined: 10-August 12

Re: Wake On Lan Code Not Working - Packet Not Waking Up?

Posted 09 August 2013 - 10:00 AM

It does not fire off an error when running the Try Catch statements in the code but it also does not wake the PC up. I am not sure if the packet just gets lost or what happens whether it is the code or the network.
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15356
  • View blog
  • Posts: 61,567
  • Joined: 12-June 08

Re: Wake On Lan Code Not Working - Packet Not Waking Up?

Posted 09 August 2013 - 10:06 AM

Basic debugging then ...

If you "Client.Send" is not throwing an socket exception we can hope the rest of the code looks okay.

What's the return value of "Client.Send"?

Then it would be to try and test this on a machine on hand. Check that machine's 'wake on lan' bios settings. Is that on? How about the machine's 'wake on lan' OS settings?
Was This Post Helpful? 0
  • +
  • -

#6 kyle_denney   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 171
  • Joined: 10-August 12

Re: Wake On Lan Code Not Working - Packet Not Waking Up?

Posted 09 August 2013 - 10:14 AM

I am checking it on a PC that is right next to me that is hard lined into the same network I am but to no avail. The NIC and BIOS allow WOL. As far as I know there is no return on this data unless I setup something as a function which I have not. Any other ideas?
Was This Post Helpful? 0
  • +
  • -

#7 ybadragon   User is offline

  • Home Owner
  • member icon

Reputation: 571
  • View blog
  • Posts: 2,647
  • Joined: 11-May 12

Re: Wake On Lan Code Not Working - Packet Not Waking Up?

Posted 09 August 2013 - 10:17 AM

Do you get your "Wake on LAN Succeded" message?

If My.Computer.Network.Ping(cboComputerName.Text) Then
  frmMessagebox.MessageDialog("Wake On Lan Succeeded", "WOL Success", 2, 2)
  frmMessagebox.ShowDialog()
End If


Was This Post Helpful? 0
  • +
  • -

#8 kyle_denney   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 171
  • Joined: 10-August 12

Re: Wake On Lan Code Not Working - Packet Not Waking Up?

Posted 09 August 2013 - 10:22 AM

No - and FYI I can see the computer that I am trying to wake up since it is right next to me - it definitely is not waking up. Even trying to wake it from hibernate or sleep does not work - I am not sure because I see other codes online that do similar things and they say they work but I am not sure what the problem is. Clearly though in the BIOS and NIC WOL is enabled, I am using the right IP/MAC and everything too. Can someone try this on a machine they have and see if it works?
Was This Post Helpful? 0
  • +
  • -

#9 ybadragon   User is offline

  • Home Owner
  • member icon

Reputation: 571
  • View blog
  • Posts: 2,647
  • Joined: 11-May 12

Re: Wake On Lan Code Not Working - Packet Not Waking Up?

Posted 09 August 2013 - 10:28 AM

If it's not saying your sent message, then it's not pinging correctly. When you say "Even trying to wake it from hibernate or sleep does not work" are you physically moving the mouse to do it and it isn't waking up? If so it could be a hardware issue. Is it a desktop or a laptop?
Was This Post Helpful? 0
  • +
  • -

#10 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15356
  • View blog
  • Posts: 61,567
  • Joined: 12-June 08

Re: Wake On Lan Code Not Working - Packet Not Waking Up?

Posted 09 August 2013 - 10:41 AM

Quote

. Even trying to wake it from hibernate or sleep does not work

well yeah.. the computer is asleep. It won't wake up. You would need to turn this feature off in the power settings.

this is a wired connection, right?

Of the myriad of other issues - have you:
- checked to see if a firewall is blocking this?
- set up the simple tcp services?


example:
http://windows7-issu...-made-easy.html
Was This Post Helpful? 0
  • +
  • -

#11 kyle_denney   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 171
  • Joined: 10-August 12

Re: Wake On Lan Code Not Working - Packet Not Waking Up?

Posted 09 August 2013 - 12:15 PM

The whole point of Wake on Lan is to wake the computer up. If I run this command from a remote PC it is supposed to reach across the network and find the MAC that is passed using this command and wake the computer up. If I try to manually wake the computer up then it works but then I wouldn't need the code I could always just hit a button. But this is for an actual business network so the computer might not always be handy to just hit a button and wake it up. I would rather run this program and pass the MAC and computer in question to it and have the program shoot the packet out to the network and wake it up. The BIOS and NIC are all configured properly and it doesn't want to do this on multiple machines on the network that are configured properly which is why I thought there might be something wrong with the code. Have any of you actually tried to port the code to an app and try it? Thanks for the feedback.

This post has been edited by kyle_denney: 09 August 2013 - 12:16 PM

Was This Post Helpful? 0
  • +
  • -

#12 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15356
  • View blog
  • Posts: 61,567
  • Joined: 12-June 08

Re: Wake On Lan Code Not Working - Packet Not Waking Up?

Posted 09 August 2013 - 12:19 PM

That's great, but I am telling you there are _OTHER_ avenues for you to debug in your setup.

If the code compiles, and does not throw an exception, I'll trust you that it is in working order and to focus on external issues.
Was This Post Helpful? 0
  • +
  • -

#13 kyle_denney   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 171
  • Joined: 10-August 12

Re: Wake On Lan Code Not Working - Packet Not Waking Up?

Posted 14 August 2013 - 09:44 AM

What issues might there be?
Was This Post Helpful? 0
  • +
  • -

#14 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15356
  • View blog
  • Posts: 61,567
  • Joined: 12-June 08

Re: Wake On Lan Code Not Working - Packet Not Waking Up?

Posted 14 August 2013 - 09:53 AM

As I said - the machine bios, the OS, etc.

I know I had an issue waking my machine up when I would VPN late at night until I told it to never go to sleep. Then there's firewalls, internal packet filtering, and so on.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1