|
-
Dec 13th, 2010, 09:07 AM
#1
Thread Starter
Addicted Member
Wake On Lan
Hi all,
Is there a way to detect programmatically if WOL is supported/enabled on a machine?
Cheers,
--Stav.
-
Dec 13th, 2010, 09:58 AM
#2
Re: Wake On Lan
I'm sure that it is and that it would be done using WMI. I have no idea what the details would be, but that gives you an avenue to investigate.
-
Dec 13th, 2010, 10:53 AM
#3
Re: Wake On Lan
vb.net Code:
'//need a reference to System.Management Imports System.Management Public Class Form1 Protected Overrides Sub OnLoad(ByVal e As System.EventArgs) MyBase.OnLoad(e) MessageBox.Show(WakeUpType.GetWakeUpType().ToString()) End Sub End Class Public Class WakeUpType '//constants Protected Const WMIQuery As String = "SELECT WakeUpType FROM Win32_ComputerSystem" Protected Const WMIElement As String = "WakeUpType" '//constructors Private Sub New() End Sub '//methods Public Shared Function GetWakeUpType() As WakeUpTypes Try Using searcher = New ManagementObjectSearcher(WakeUpType.WMIQuery) Using results = searcher.Get() For Each result In results Dim item = result.Item(WakeUpType.WMIElement) If item IsNot Nothing AndAlso _ [Enum].IsDefined(GetType(WakeUpTypes), item) Then Return CType(item, WakeUpTypes) End If Next End Using End Using Catch ex As ManagementException End Try Return WakeUpTypes.Unknown End Function '//enumerations Public Enum WakeUpTypes As UShort Reserved = &H0 Other = &H1 Unknown = &H2 APMTimer = &H3 ModemRing = &H4 LANRemote = &H5 PowerSwitch = &H6 PCIPME = &H7 ACPowerRestorted = &H8 End Enum End Class
Reference
-
Dec 13th, 2010, 12:05 PM
#4
Thread Starter
Addicted Member
Re: Wake On Lan
Thanks for the replies guys.
ForumAccount, I have tried the code and it returns "PowerSwitch". There is only 1 "result" in "results" by the way.
The msdn reference page confused me a bit too. It says the following:
WakeUpType
Data type: uint16
Access type: Read-only
Event that causes the system to power up.
That made me think that it might be refering to the last wake up event...???
Just to eliminate any doubts that were created I have tried running the code after waking up the machine using WOL and the result of the code was once again "PowerSwitch"...
Any more input will be much appreciated.
Cheers,
--Stav.
-
Dec 13th, 2010, 01:39 PM
#5
Re: Wake On Lan
I'm not really sure at this point. When you say 'enabled on a machine' do you mean enabled in the bios? Or enabled in the network adapter?
-
Dec 13th, 2010, 02:04 PM
#6
Thread Starter
Addicted Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|