PINTO1927

Information about computers on a Network

2 posts in this topic

Hello guys,
I analyzed script that you find below and I planned to add more information to the ListView, type:

- Username login
- Now the computer power

You think you can take this information and show them in the table?

#include <Array.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
Dim $aBrowdcast[4]
$aBrowdcast[0]=@IPAddress1
$aBrowdcast[1]=@IPAddress2
$aBrowdcast[2]=@IPAddress3
$aBrowdcast[3]=@IPAddress4
$filemaclist="MACLIST.DAT"

Dim $MACAddressList[1]
$MACAddressList[0] = "08000e42faa7"

; ===================================================================
; Gui
;   
; ===================================================================
$mainwindow=GUICreate("WOLLE",450,300)
$mwbtnExit=GUICtrlCreateButton("Exit",350,150,100)
$mwbtnGetMac=GUICtrlCreateButton("Get Mac adresses",10,150,100)
$mwbtnWakeupall=GUICtrlCreateButton("Wake up all in list",130,150,100)
$mwbtnWakeupSelected=GUICtrlCreateButton("Wake up selected",240,150,100)
$mwlblIpRange=GUICtrlCreateLabel("Enter Start and End IP for search, will only search for last segment, sorry....",10,115,200,30)

$mvinpIpStart=GUICtrlCreateInput("192.168.0.1",250,120,100,15)
$mvinpIpStop=GUICtrlCreateInput("192.168.0.10",350,120,100,15)
$mvinpWakeupTimeHH=GUICtrlCreateCombo("0",10,220,40)
$mvinpWakeupTimeMM=GUICtrlCreateCombo("00",50,220,40)
$mvinpWakeupTimeSS=GUICtrlCreateCombo("00",90,220,40)
FillTimeCombos()
$mwbtnActivateTimer=GUICtrlCreateButton("Activate Timer",290,220,120)
$mwbtnSetTimertoNow=GUICtrlCreateButton("Set Timer to now",160,220,120)
$mwbtnReadMacListFile=GUICtrlCreateButton("MACLIST.DAT",260,50,120)
$mwlvMacadresses=GUICtrlCreateListView("MacAdresses   |IP                ",10,10,250,100)
$mwlblStatus=GUICtrlCreateLabel("Status:",10,180,400)
readmacfile()
setTimertoNow()
$boolTimerActive=0
GUISetState(@SW_SHOW)
    While 1
        $msg = GUIGetMsg()
        select 
            case $msg = $GUI_EVENT_CLOSE 
                ExitLoop
            case $msg = $mwbtnExit 
                ExitLoop
            case $msg = $mwbtnWakeupall 
                wol_all()
            case $msg = $mwbtnGetMac 
                getmacinrange()
            case $msg = $mwbtnGetMac 
                getmacinrange()
            case $msg = $mwbtnWakeupSelected 
                wol_selected()              
            case $msg = $mwbtnReadMacListFile 
                readmacfile()
            case $msg = $mwbtnActivateTimer
                if $boolTimerActive=1 Then
                    TimerDisable(0)
                Else
                    TimerDisable(1)
                endif
            case $msg = $mwbtnSetTimertoNow 
                setTimertoNow()


                
            EndSelect   
            if $boolTimerActive=1 Then
                CheckWakeup()
                sleep(100)
            endif
    WEnd
    GUIDelete()
    exit

; ===================================================================
; Function: setTimertoNow
;   sets the thre time controls to the current time 
; ===================================================================
func setTimertoNow()
    guictrlsetdata($mvinpWakeupTimeHH,@HOUR)
    guictrlsetdata($mvinpWakeupTimeMM,@MIN)
    guictrlsetdata($mvinpWakeupTimeSS,@SEC)
EndFunc

; ===================================================================
; Function: TimerDisable
;   Toggle for the Timer button 
; ===================================================================
func TimerDisable($TimerState)
    $boolTimerActive=$TimerState
    if $TimerState = "0" Then
        GUICtrlSetState($mwbtnExit,$GUI_ENABLE)
        GUICtrlSetState($mwbtnGetMac,$GUI_ENABLE)
        GUICtrlSetState($mwbtnWakeupall,$GUI_ENABLE)
        GUICtrlSetState($mwbtnWakeupSelected,$GUI_ENABLE)
        GUICtrlSetState($mvinpIpStart,$GUI_ENABLE)
        GUICtrlSetState($mvinpIpStop,$GUI_ENABLE)
        GUICtrlSetState($mvinpWakeupTimeHH,$GUI_ENABLE)
        GUICtrlSetState($mvinpWakeupTimeMM,$GUI_ENABLE)
        GUICtrlSetState($mvinpWakeupTimeSS,$GUI_ENABLE)
        GUICtrlSetState($mwbtnReadMacListFile,$GUI_ENABLE)
        GUICtrlSetState($mwbtnSetTimertoNow,$GUI_ENABLE)
        GUICtrlSetData($mwbtnActivateTimer," Activate Timer")
        setStatusMsg("Timer deactivated")
        
    Else
        GUICtrlSetState($mwbtnExit,$GUI_DISABLE)
        GUICtrlSetState($mwbtnGetMac,$GUI_DISABLE)
        GUICtrlSetState($mwbtnWakeupall,$GUI_DISABLE)
        GUICtrlSetState($mwbtnWakeupSelected,$GUI_DISABLE)
        GUICtrlSetState($mvinpIpStart,$GUI_DISABLE)
        GUICtrlSetState($mvinpIpStop,$GUI_DISABLE)
        GUICtrlSetState($mvinpWakeupTimeHH,$GUI_DISABLE)
        GUICtrlSetState($mvinpWakeupTimeMM,$GUI_DISABLE)
        GUICtrlSetState($mvinpWakeupTimeSS,$GUI_DISABLE)
        GUICtrlSetState($mwbtnReadMacListFile,$GUI_DISABLE)
        GUICtrlSetState($mwbtnSetTimertoNow,$GUI_DISABLE)       
        
        GUICtrlSetData($mwbtnActivateTimer," De-Activate Timer")

        EndIf
EndFunc


; ===================================================================
; Function: CheckWakeup
; critical only equal time will trigger (needs omething better like a small range)
; ===================================================================
func CheckWakeup()
    
    $strWakeupTime=GUICtrlRead($mvinpWakeupTimeHH)&GUICtrlRead($mvinpWakeupTimeMM)&GUICtrlRead($mvinpWakeupTimess)
    $strNow=@HOUR&@MIN&@SEC
    setStatusMsg("Current time:"&@HOUR&":"&@MIN&":"&@SEC)
    if $strNOW = $strWakeupTime Then
        SoundPlay(@WindowsDir & "\media\tada.wav",0)
        wol_all()
    EndIf
EndFunc 
; ===================================================================
; Function: FillTimeCombos
;          filling the controls with data 
; ===================================================================
func FillTimeCombos()
    for $i=1 to 23 
            GUICtrlSetData($mvinpWakeupTimeHH,$i)
        Next
    for $i=1 to 59
            GUICtrlSetData($mvinpWakeupTimeMM,$i)
            GUICtrlSetData($mvinpWakeupTimeSS,$i)
        Next
    
EndFunc


; ===================================================================
; Function: readmacfile
;           reads mac list in ini format
; ===================================================================
func readmacfile($filemaclist="MACLIST.DAT")
    if FileExists($filemaclist) Then
        $aMaclist=IniReadSection(@scriptdir&"\"&$filemaclist,"MACLISTE")
        _GUICtrlListView_DeleteAllItems($mwlvMacadresses) 
        for $i  = 1 to $aMaclist[0][0] 
                GUICtrlCreateListViewItem(""&$aMaclist[$i][1]&"|"&$aMaclist[$i][0]&"", $mwlvMacadresses)    
            Next
    EndIf
            
    
    EndFunc
; ===================================================================
; Function: getmacinrange
;           simple try to get all mac adresses from a given range (only last segment)
; ===================================================================
func getmacinrange()
    FileDelete(@ScriptDir&"\"&$filemaclist)
    $aIpStart=StringSplit(GUICtrlRead($mvinpIpStart),".")
    $aIpStop=StringSplit(GUICtrlRead($mvinpIpStop),".")
    
    
                for $IpSegD = $aIpStart[4] to $aIpStop[4]
                    get_mac($aIpStart[1]&"."&$aIpStart[2]&"."&$aIpStart[3]&"."&$IpSegD) 
                Next
                readmacfile()

EndFunc

; ===================================================================
; Function: wol_selected
;   sents magic paket to the macadress selected in listviw
; ===================================================================
func wol_selected()
    $aSelectedItems=_GUICtrlListView_GetSelectedIndices($mwlvMacadresses,true)
    if $aSelectedItems[0] > 0 Then
        $macadress=_GUICtrlListView_GetItemText($mwlvMacadresses,$aSelectedItems[1])
        for $adapter in $aBrowdcast 
            wol_adapter($adapter,$macadress)
        Next
        setStatusMsg("is "&$adapter&" awake?")
    EndIf
    
    
endfunc
; ===================================================================
; Function: wol_all
; 
; ===================================================================
func wol_all()
    
    for $adapter in $aBrowdcast 
        wol_adapter_all($adapter)
    Next
    setStatusMsg("All awake?")
    
endfunc
; ===================================================================
; Function: setStatusMsg($msgtext)
;           $msg    --- Message for status text
; ===================================================================
func setStatusMsg($msgtext)
    GUICtrlSetData($mwlblStatus,"Status:"&$msgtext)
endfunc
; ===================================================================
; Function: wol_adapter($adapter,$$macadress)
;           $adapter        --- is the ipadress of the adapter
;          $macadress       --- is the macadress
; ===================================================================

func wol_adapter($adapter,$macadress)
    if $adapter <> "0.0.0.0" Then
        $IPADRESS = StringSplit($adapter,".")
        $Broadcast = $IPADRESS[1] & "." & $IPADRESS[2] & "." & $IPADRESS[3] & "." & "255"

        $String=""
                setStatusMsg("Sent WOL via "&$Broadcast&" for:"&$macadress)
                WOL($Broadcast,$macadress)
    EndIf
    
    EndFunc

; ===================================================================
; Function: wol_adapter($adapter)
;           $adapter        --- is the ipadress of the adapter
; ===================================================================

func wol_adapter_all($adapter)
    if $adapter <> "0.0.0.0" Then
        $IPADRESS = StringSplit($adapter,".")
        $Broadcast = $IPADRESS[1] & "." & $IPADRESS[2] & "." & $IPADRESS[3] & "." & "255"

        $String=""
      
        FOR $macadress IN $MACAddressList
                setStatusMsg("Sent WOL via "&$Broadcast&" for:"&$macadress)
                WOL($Broadcast,$macadress)
                Sleep(1000)
        Next
    EndIf
    
    EndFunc

; ===================================================================
; Function: WOL($Broadcast,$element)
;          $Broadcast       --- is ipadress of adapter with 255 at the End
;           $MACAddress     --- is the macadress 
; ===================================================================

; Wake up on Lan Function (Open connection and broadcast to Lan)
Func WOL($Broadcast,$MACAddress)
UDPStartUp()
$connexion = UDPOpen($Broadcast,7)
UDPSend($connexion, GenerateMagicPacket($MACAddress))
UDPCloseSocket($connexion)
UDPShutdown()
EndFunc


; This function convert a MAC Address Byte (e.g. "1f") to a char
Func HexToChar($strHex)
    
    Return Chr(Dec($strHex))
    
EndFunc

; This function generate the "Magic Packet"
Func GenerateMagicPacket($strMACAddress)
    
    $MagicPacket = ""
    $MACData = ""
    
    For $p = 1 To 11 Step 2
        $MACData = $MACData & HexToChar(StringMid($strMACAddress, $p, 2))
    Next
    
    For $p = 1 To 6
        $MagicPacket = HexToChar("ff") & $MagicPacket
    Next
    
    For $p = 1 To 16
        $MagicPacket = $MagicPacket & $MACData
    Next
    
    Return $MagicPacket
    
EndFunc

; ===================================================================
; Function: get_mac($remote_ip,$filemaclist)
;           $remote_ip      --- remote ip
;           $filemaclist    --- file in ini format
; enhanced by TheSovereign - skip local mac adress
; ===================================================================
func get_mac($remote_ip,$filemaclist="MACLIST.DAT")
                    Ping($remote_ip,200)
                    if @error =0 Then
                        $arpinfo = Run(@ComSpec & " /c ARP -a "&$remote_ip, @SystemDir, @SW_HIDE, 2)
                        sleep(200)
                        $output = StdoutRead($arpinfo, -1)
                            $aOutputLine=StringSplit($output,@CRLF)
                            If UBound($aOutputLine) > 5 Then ; <=== added so script doesn't choke when processing the IP for the computer it's running on
                                $macadress=Stringmid($aOutputLine[7],25,17)
                                $macadress=StringReplace($macadress,"-","")
                                IniWrite(@ScriptDir&"\"&$filemaclist,"MACLISTE",$remote_ip,$macadress)
                                setStatusMsg("Found maclist "&$macadress)
                            EndIf ; <=== and this one...

                        Else
                            setStatusMsg("Host "&$remote_ip&" not reachable")
                            Return
                        endif
                    EndFunc

Source: https://www.autoitscript.com/forum/topic/29772-copyright-free-wake-on-lan-script/

 

Share this post


Link to post
Share on other sites



You could use WMI to extract this information from a remote computer. Please check Scriptomatic in the Example Scripts forum. It generates the needed AutoIt code for you.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • ModemJunki
      By ModemJunki
      Hello,
      In Windows 10 PowerShell, one can do this to change the metric for a NIC in Windows 10:
      Get-NetAdapter | Where-Object -FilterScript {$_.InterfaceAlias -Eq "Ethernet 2"} | Set-NetIPInterface -InterfaceMetric 2 I know I can script the above PowerShell line (and it works!), but I wanted to try something I hadn't done before after looking into jguinch's most excellent Network configuration UDF. I wanted to make use of the SetIPConnectionMetric method in the WMI classes. There is an example VBscript here but this is not for Windows 10. Using AutoIT would also give better control over capturing error return codes than with PowerShell.
      But I cannot get my script to work! The return from SetIPConnectionMetric() is 0, which would indicate success. Yet the change does not happen. I also tried WMI methods using .put_ but this fails.
      Anyone more experienced than I have ideas to make this work?
      #RequireAdmin _SetNicInterfaceMetric2("Ethernet 2", "2") Func _SetNicInterfaceMetric2($NIC_NAME, $METRIC) Local $s_setIndx = 0 $objWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2") $colNICItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionID = '" & $NIC_NAME & "'", "WQL") If IsObj($colNICItems) Then For $objItem In $colNICItems $s_nicIndex = $objItem.Index Next ConsoleWrite("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE Index = '" & $s_nicIndex & "'" & @CRLF) $colNAC = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE Index = '" & $s_nicIndex & "'", "WQL") If IsObj($colNAC) Then For $objNetCard In $colNAC If $METRIC <> $objNetCard.IPConnectionMetric Then ConsoleWrite("Metric was set to " & $objNetCard.IPConnectionMetric & ". Setting to " & $METRIC & "." & @CRLF) $s_isSet = $objNetCard.SetIPConnectionMetric($METRIC) ConsoleWrite("SetIPConnectionMetric Result = " & $s_isSet & @CRLF) Else ConsoleWrite("Metric is already set to " & $METRIC & @CRLF) EndIf Next EndIf EndIf EndFunc ;==>_SetNicInterfaceMetric2  
    • harvester2001
      By harvester2001
      Hi
      I need your help I need create broadcast text message/notification to multiple lan clients. I can install listener program on pc its not a problem.
      But I don`t know how to start, could somebody write me example script how broadcast script and client who listen non stop for message should look like.
      I try to find example on forum but I have problem to understand those scripts.
      Many thx for help.
    • AoRaToS
      By AoRaToS
      s!mpL3 LAN Messenger as the name suggests is a messenger designed and developed to offer chat communication over Local Area Networks while being as simple to use as possible. This project started way back in 2008 with only basic functionality and is regularly updated with new features in order to make it more useful and user friendly. What I wanted was a simple, small, serverless program that would work without installation cause that was the ideal combination for my workplace back then, so I ended up with this!

      I have attached some images from various versions:
      Check the rest below! (from various versions)

      Previous downloads: 7430 (Without counting the ones from the Downloads section.)

      Current version 2.9.8.8! [30/09/2015]  s!mpL3 LAN Messenger.zip
      [Attachment version updated to 2.9.8.8]  

      s!mpL3 LAN Messenger version 2.9.8.8 - [30/09/2015]

      1. Removed some test code that could cause message boxes to pop up for Windows versions prior to Windows 10.


      You can view/download the full change log here: ChangeLog.txt

      Tested and working on Windows XP, Windows Vista, Windows 7, Windows 8, Windows 8.1 and Windows 10.


      Things you need to know before trying it:

      1. Start the program, select one or more connections from what's available and click Connect (If a firewall notice comes up, click 'Allow' or 'Add Exception')
      When someone else on your network does the same, they will appear in your TreeView and you will appear in theirs, double click their name and chat!

      2. s!mpL3 LAN Messenger does not require a server to be running, it's standalone.

      3. On the first run an .ini file is created at @LocalAppDataDirs!mpL3 LAN Messenger which stores the settings so that they are used every time you run the application. If you delete the .ini file it will be created again (with default settings at program startup or with your selected settings if you press Save from the Preferences window).

      4. All communication is encrypted using AES so it's quite secure against Network sniffers.

      5. You can send files and folders by dragging and dropping them in a conversation window. Folders are compressed before being sent. You can also drop multiple items to be sent.

      6. There is a "Hide" button located in the tray right click context menu that will hide all open windows. You can assign a Hotkey combination from Preferences. The default combination is Ctrl+H.

      7. s!mpL3 LAN Messenger uses port 60000 by default. You can change the port used by adding "Port=****" (without quotes, stars represent numbers) to the Config file described above. Communication is UDP.

      8. There is an Updater feature you can use to always have the latest available version, you only need an internet connection for that to work. You might need to clear your Internet Explorer Temporary Files in order for it to find an updated version.

      9. You can Hide + Lock s!mpL3 LAN Messenger so it'll require a password in order to "Appear". To enable this, go to the Security Preferences.

      10. Note that versions after 2.9.8.1 are not compatible with previous versions due to the encryption used being changed. I recommend using the latest version, or at least use the same version over the LAN.


      Important Notice:

      I will not be releasing the source code, however, I might share some parts of code if requested...
      If you choose to decompile this software, don't release the source code.



    • iamtheky
      By iamtheky
      Message is broken out further and requires extra massaging, that and I am formatting it for eventual Neo4j graph sexiness.
      #include <AutoItConstants.au3> #include<array.au3> #RequireAdmin $outfile = "test_PS_csv_failures.csv" If fileexists($outfile) then FileDelete($outfile) $iPID = run("powershell get-eventlog -logname security -Message '*An account failed to log on*' | select Index,TimeGenerated,Message | format-list" , "", @SW_HIDE , $stdout_child) $sOutput = "" While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop EndIf WEnd $aStr = stringsplit($sOutput , @CRLF , 3) For $i = ubound($aStr) - 1 to 0 step - 1 If NOT stringinstr($aStr[$i] , ":") Then _ArrayDelete($aStr , $i) Next ;~ _ArrayDisplay($aStr) $sFinal = "" $sLine = "" $k = 0 for $i = 0 to 29 $sLine &= stringregexpreplace(stringstripws($aStr[$i] , 8) , "(\:.*)" , "") & "," next $sFinal &= StringTrimRight($sLine , 1) & @LF $sLine = "" for $i = 30 to ubound($aStr) - 1 $aStr[$i] = stringreplace($aStr[$i] , "," , "_") $sLine &= stringregexpreplace($aStr[$i] , "(\A.*\D:)" , "") & "," $k += 1 If $k = 30 Then If NOT StringInStr($sLine , @UserName) Then $sFinal &= StringTrimRight($sLine , 1) & @LF $sLine = "" $k = 0 EndIf next ;~ msgbox(0, '' , $sFinal) filewrite($outfile , $sFinal) shellexecute($outfile)  
    • shaggy89
      By shaggy89
      Hi all,
      Im hoping some could help me out.
      I'm using an IM client that sends messages via UDP.
      I was wondering is there a way I could make a button with a pre canned message to send to all online users automatically E.g "about to get coffee place your oder" send to all online
      Saves sending to one person at a time.
       
      Cheers
      Shaggy
       
      Edit ::::
       
      After looking into it more,  there are scripts on the forum that do the job i need all i have to do edit them to my needs
       
      Thanks anyways