I can never find a good wake on lan sample when I need one. So I’m saving it ahead
of time. This is a Wake On Lan app using .Net 2.0 from Bart
De Smet’s BlogExcerpt
Some years ago I created a WOL client for Visual Basic 6 using WinSock stuff which
was a pretty nice project that wasn’t so straightforward to do. Today, I’m creating
a little lightweight management tool to apply configuration changes to computers in
a network over night, even when the machines are asleep. Shutting down a machine after
maintenance is pretty simple to do using the ExitWindowsEx API, but waking a machine
up requires some WOL functionality. So I decided to recreate the application (which
I couldn’t find anymore in my messy non-existing archive) in managed code (.NET
Framework 2.0). More information about WOL can be found on Wikipedia.
B#
.NET Blog : Wake on LAN in C#.
Random Posts
Loading…
I modified the C# code to VB.Net. I created a simple form with 1 text box to put the mac addressin and a button.Imports System.NetImports System.Net.SocketsImports System.TextPublic Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click WakeUp(TextBox1.Text) End Sub Private Shared Sub WakeUp(ByVal mac As String) Dim client As UdpClient = New UdpClient() client.Connect(IPAddress.Broadcast, 40000) Dim buf(101) As Char Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(buf) For x As Integer = 0 To 5 sendBytes(x) = CInt("&HFF") Next Dim MacAddress As String MacAddress = Replace(mac, "-", "") Dim i As Integer = 6 For x As Integer = 1 To 16 sendBytes(i) = CInt("&H" + MacAddress.Substring(0, 2)) sendBytes(i + 1) = CInt("&H" + MacAddress.Substring(2, 2)) sendBytes(i + 2) = CInt("&H" + MacAddress.Substring(4, 2)) sendBytes(i + 3) = CInt("&H" + MacAddress.Substring(6, 2)) sendBytes(i + 4) = CInt("&H" + MacAddress.Substring(8, 2)) sendBytes(i + 5) = CInt("&H" + MacAddress.Substring(10, 2)) i += 6 Next client.Send(sendBytes, sendBytes.Length) End SubEnd Class
Hi,Thanks for linking to my blog! Can you change the URL of the WOL sample to http://blogs.bartdesmet.net/bart/archive/2006/04/02/3858.aspx, which will be much more convenient to find it on my blog as I’m a pretty frequent blogger
Thanks and keep up the good work,Bart
Thanks a lot!! This really helped me and I could actually find a decent WOL VB.Net sample!