Kaseya Community

Yet another WOL script

  • Here is a simple WOL script I recently wrote for waking offline PCs from another PC that is online on the same LAN by using the RW.EXE utility. This script wakes one system at a time (see script description) and uses Kaseya SQL Views so that you don't have to deal with MAC addresses directly.

    Step 4 uses the Windows CLI FOR command to remove dashes from the MAC address as required by RW.EXE.

     
    Script Name: WOL
    Script Description: Wake-On-LAN Script: uses a freeware RW.EXE utility to wake up a WOL-Enabled PC from an online PC on the same LAN against which this script is ran (both PCs need to have Kaseya agents on them).

    Modify STEP 3 and change AGENTID.GROUPID to the full name of the agent you are trying to wake up.

    IF True
    THEN
    Get Variable
    Parameter 1 : 10
    Parameter 2 :
    Parameter 3 : agentTemp
    OS Type : 1
    Write File
    Parameter 1 : #agentTemp#\rw.exe
    Parameter 2 : VSASharedFiles\rw.exe
    OS Type : 1
    Get Variable
    Parameter 1 : 11
    Parameter 2 : vMachine/MacAddr/AGENTID.GROUPID
    Parameter 3 : macAddr
    OS Type : 1
    Execute Shell Command
    Parameter 1 : for /f "tokens=1-6 delims=-" %i in ('echo #macAddr#') do @echo %i%j%k%l%m%n >> #agentTemp#\mac.txt
    Parameter 2 : 1
    OS Type : 1
    Get Variable
    Parameter 1 : 1
    Parameter 2 : #agentTemp#\mac.txt
    Parameter 3 : mac
    OS Type : 1
    Execute Shell Command
    Parameter 1 : #agentTemp#\rw.exe /m:#mac# >> #agentTemp#\result.txt
    Parameter 2 : 1
    OS Type : 1
    Get Variable
    Parameter 1 : 1
    Parameter 2 : #agentTemp#\result.txt
    Parameter 3 : wolResult
    OS Type : 1
    Write Script Log Entry
    Parameter 1 : #wolResult#
    OS Type : 1
    Delete File
    Parameter 1 : #agentTemp#\rw.exe
    OS Type : 1
    Delete File
    Parameter 1 : #agentTemp#\mac.txt
    OS Type : 1
    Delete File
    Parameter 1 : #agentTemp#\result.txt
    OS Type : 1
    ELSE


    Legacy Forum Name: Yet another WOL script,
    Legacy Posted By Username: ed@securemycompany.com
  • Any idea how to modify this script to get a list of machines from its current group id, and wake them all up?

    BTW

    It works brilliantly otherwise.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: Nathan Coulthard
  • Edit christian internet dating sites - Scripts & Agent Procedures - Forums - Kaseya Community singles indian indian dating indian single free married but looking dating sites easy adult dating sim free adult dating ipswich massachusetts woman dating younger men


    [edited by: Anonymous at 1:03 AM (GMT -8) on 2-18-2011] Edit christian internet dating sites - Scripts & Agent Procedures - Forums - Kaseya Community singles indian indian dating indian single free married but looking dating sites easy adult dating sim free adult dating ipswich massachusetts woman dating younger men
  • rather than making a new thread ill bump an old one. I have been searching for a way to enable WOL in xp/vista through the drivers but havent had much luck. so far all i have come across is:

    http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/a159ec1f-1d6e-4660-bbea-8237f9cf9db2/

    edit: made some progress found this little gem on the net. only thing its missing is to toggle
    "Wake from shutdown" on the other tab
    ill post here again if i find anything
    '************************************************************************
    '* VBS Script to:
    '* Enable/Disable showing the icon in your system tray for connected NICs
    '* Enable/Disable Power Management for Connected NICs
    '*
    '* 8 MAY 06 - Jase McCarty
    '************************************************************************

    'Let's setup our variables
    Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE info for registry writes
    Dim objReg 'Registry Object
    Dim objWMIService 'WMI Service Object
    Dim arrayNetCards 'Array of all connected NICs
    Dim objNetCard 'A specific NIC
    Dim strNICguid '
    Dim strShowNicKeyName 'Key Specific to the Network Adapters in CurrentControlSet
    Dim strShowNicKeyName001 'Key Specific to the Network Adapters in CurrentControlSet001
    Dim strPnPCapabilitesKeyName 'Key Specific to the Network Adapters in CurrentControlSet
    Dim strPnPCapabilitesKeyName001 'Key Specific to the Network Adapters in CurrentControlSet001
    Dim strComputer 'Name of computer to modify


    strComputer = "." 'Period = local computer

    strShowNicKeyName = "SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\"
    strShowNicKeyName001 = "SYSTEM\CurrentControlSet001\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\"
    strPnPCapabilitiesKeyName = "SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\"
    strPnPCapabilitiesKeyName001 = "SYSTEM\CurrentControlSet001\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\"

    ShowNicdwValue = 0 '1 for ON, 0 for OFF

    PnPdwValue = 288 '56 to disable "Allow the computer to turn off this device to save power."

    '48 to enable "Allow the computer to turn off this device to save power."

    '32 to enable "Allow the computer to turn off this device to save power."
    ' and enable "Allow this device to bring the computer out of standby."

    '288 to enable "Allow the computer to turn off this device to save power."
    ' and enable "Allow this device to bring the computer out of standby."
    ' and enable "Only allow management stations to bring the computer out of standby."


    On Error Resume Next
    Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
    Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

    'Look for the NICs that have IP enabled
    Set arrayNetCards = objWMIService.ExecQuery ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

    'Make changes on the NICs that have IP enabled
    For Each objNetCard in arrayNetCards
    strNICguid = objNetCard.SettingID 'Get the GUID of the NIC
    strDeviceID = Mid(objNetCard.Caption,6,4) 'Get the DeviceID of the NIC

    'Change the "Show icon in notification area when connected value"
    objReg.SetDWORDValue HKLM, strShowNicKeyName & strNICguid & "\Connection", "ShowIcon", ShowNicdwValue
    objReg.SetDWORDValue HKLM, strShowNicKeyName001 & strNICguid & "\Connection", "ShowIcon", ShowNicdwValue

    'Change the Power Management Values
    objReg.SetDWORDValue HKLM, strPnPCapabilitiesKeyName & strDeviceID & "\","PnPCapabilities",PnPdwValue
    objReg.SetDWORDValue HKLM, strPnPCapabilitiesKeyName001 & strDeviceID & "\","PnPCapabilities",PnPdwValue
    Next

    Set objReg = Nothing
    Set objWMIService = Nothing



    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: Wilfred