Jump to content

PC Beacon


Bert
 Share

Recommended Posts

This tool is for the tech who supports a corporate environment. Say you are doing PC replacements. You know the IP address of the PC you need to find. You can remote into the PC. You know the floor where the PC is located. BUT...you not exactly sure where on the floor the PC is located. All the PCs on the floor are the same model, so knowing what model it is doesn't help at all. This is where this little tool will come in handy.

To use the tool, just do the following:

  • Remote into the PC
  • log on
  • Run the tool
  • configure the tool to your need, and press start.

When you find the PC, press Ctrl+Alt+C to turn off the beacon.

When choosing how you want to run the beacon, you can do:

  • flashing red screen
  • display a message in LARGE COMIC SANS FONT
  • Audio - either beep or Microsoft voice that will read the text you have put in the message.

Another good use if for remote support to help a user locate a PC that they need to find.

#Region converted Directives from I:\autoit scrips\PCBeacon\PCBeacon.au3.ini
#AutoIt3Wrapper_aut2exe=C:\Program Files\AutoIt3\beta\Aut2Exe\Aut2Exe.exe
#AutoIt3Wrapper_icon=C:\Documents and Settings\a4mh3\Desktop\autoit scrips\icons\Beaconinthenight.ico
#AutoIt3Wrapper_outfile=C:\Documents and Settings\a4mh3\Desktop\autoit scrips\PCBeacon\PCBeacon.exe
#AutoIt3Wrapper_PassPhrase=FnpT01
#AutoIt3Wrapper_Res_Comment=http://www.hiddensoft.com/autoit3/compiled.html
#AutoIt3Wrapper_Res_Description=AutoIt v3 Compiled Script
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=n
#AutoIt3Wrapper_Run_AU3Check=4
#EndRegion converted Directives from I:\autoit scrips\PCBeacon\PCBeacon.au3.ini
;
Opt("TrayIconHide", 1)
#include <WindowsConstants.au3>
#include <inet.au3>
#include <GUIConstantsEx.au3>

HotKeySet("^!c", "_exit")

Dim $voice = ObjCreate("Sapi.SpVoice")
Dim $chk_1, $chk_2, $chk_3, $chk_4, $chk_5, $chk_6, $voice

$gui1 = GUICreate("PCBeacon 1.0", 392, 323, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$Checkbox_1 = GUICtrlCreateCheckbox("Flashing screen", 20, 20, 120, 20)
$Checkbox_2 = GUICtrlCreateCheckbox("Audio", 20, 60, 120, 20)
$Checkbox_3 = GUICtrlCreateCheckbox("Message to show", 20, 100, 120, 30)
$Input_4 = GUICtrlCreateInput("", 20, 150, 350, 80)
$Button_5 = GUICtrlCreateButton("Start", 60, 260, 70, 30)
$Button_6 = GUICtrlCreateButton("Exit", 160, 260, 70, 30)
$radio_7 = GUICtrlCreateRadio("Talk", 220, 60, 50, 20)
$radio_8 = GUICtrlCreateRadio("beep", 280, 60, 50, 20)
$group_9 = GUICtrlCreateGroup("", 200, 50, 150, 35)
$lable_10 = GUICtrlCreateLabel("PCBeacon 1.0" & @CRLF & "Volly Productions" & @CRLF & "November 2006", 260, 260, 120, 90)
GUICtrlSetData($Input_4, IniRead("PCB.inr", "text", "text", ""))
GUICtrlSetState($Checkbox_3, $GUI_DISABLE)
GUICtrlSetState($Input_4, $GUI_DISABLE)
GUICtrlSetState($radio_7, $GUI_DISABLE)
GUICtrlSetState($radio_8, $GUI_DISABLE)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Checkbox_1
            $a = GUICtrlRead($Checkbox_1)
            If $a = $GUI_CHECKED Then
                GUICtrlSetState($Checkbox_3, $GUI_ENABLE)
                GUICtrlSetState($Input_4, $GUI_ENABLE)
            EndIf
            If $a = $GUI_UNCHECKED Then
                GUICtrlSetState($Checkbox_3, $GUI_DISABLE)
                GUICtrlSetState($Input_4, $GUI_DISABLE)
            EndIf
        Case $msg = $Checkbox_2
            $b = GUICtrlRead($Checkbox_2)
            If $b = $GUI_CHECKED Then
                GUICtrlSetState($radio_7, $GUI_ENABLE)
                GUICtrlSetState($radio_8, $GUI_ENABLE)
            EndIf
            If $b = $GUI_UNCHECKED Then
                GUICtrlSetState($radio_7, $GUI_DISABLE)
                GUICtrlSetState($radio_8, $GUI_DISABLE)
            EndIf
        Case $msg = $radio_7
            $c = GUICtrlRead($radio_7)
            $cc = GUICtrlRead($Checkbox_2)
            Select
                Case $c = $GUI_CHECKED
                    GUICtrlSetState($Input_4, $GUI_ENABLE)
                Case $c = $GUI_UNCHECKED
                    GUICtrlSetState($Input_4, $GUI_DISABLE)
                Case $cc = $GUI_UNCHECKED
                    GUICtrlSetState($Input_4, $GUI_DISABLE)
            EndSelect
        Case $msg = $radio_8
            $d = GUICtrlRead($radio_7)
            Select
                Case $d = $GUI_CHECKED
                    GUICtrlSetState($Input_4, $GUI_DISABLE)
                Case $d = $GUI_UNCHECKED
                    GUICtrlSetState($Input_4, $GUI_DISABLE)
                    
            EndSelect
            
        Case $msg = $Button_5;start
            MsgBox(0, "Important!", 'Once started, you will need to use "CTRL + ALT + C" to end the program')
            _start()
        Case $msg = $Button_6;start
            Exit
        Case Else
        ;;;
    EndSelect
WEnd
Exit

Func _exit()
    Exit
EndFunc  ;==>_exit

Func _start()
    Local $splash
    $chk_1 = GUICtrlRead($Checkbox_1);splash
    $chk_2 = GUICtrlRead($Checkbox_2);beep
    $chk_3 = GUICtrlRead($Checkbox_3);message
    $chk_4 = GUICtrlRead($Input_4)
    IniWrite("PCB.inr", "text", "text", $chk_4)
    $chk_5 = GUICtrlRead($radio_7);splash
    $chk_6 = GUICtrlRead($radio_8)
    GUISetState(@SW_HIDE, $gui1)
    If $chk_1 = $GUI_CHECKED Then _loop1()
    If $chk_2 = $GUI_CHECKED Then _loop2()
EndFunc  ;==>_start

Func _loop1()
    $gui2 = GUICreate("", 600, 500, -1, -1, "", 0x00000008)
    GUISetBkColor(0xE0FFFF, $gui2)
    $lable = GUICtrlCreateEdit("", 100, 25, 400, 400, 0x0004 + 0x0800 + 0x0001)
    If $chk_3 = $GUI_CHECKED Then
        $font = "Comic Sans MS"
        GUICtrlSetData($lable, $chk_4)
        GUICtrlSetFont($lable, 22, 900, "", $font)
    EndIf
    GUISetState(@SW_SHOW, $gui2)
    While 1
        $getpos = MouseGetPos()
        MouseMove($getpos[0] + 1, $getpos[1], 0)
        MouseMove($getpos[0] - 1, $getpos[1], 0)
        If $chk_2 = $GUI_CHECKED Then
            If $chk_5 = $GUI_CHECKED Then
                _Talk($chk_4, 0.75, 100)
                Sleep(2000)
            EndIf
            if  $chk_6 = $GUI_CHECKED Then Beep(500, 1000)
        Else
            Sleep(1000)
        EndIf
        SplashImageOn("", @ScriptDir & "\red.bmp", @DesktopWidth, @DesktopHeight)
        Sleep(1000)
        SplashOff()
    WEnd
EndFunc  ;==>_loop1

Func _loop2()
    While 1
        If $chk_5 = $GUI_CHECKED Then
            _Talk($chk_4, 0.75, 100)
            Sleep(2000)
        EndIf
        if  $chk_6 = $GUI_CHECKED Then
            Beep(300, 200)
            Beep(400, 500)
            Beep(500, 200)
            Beep(600, 500)
            Sleep(3000)
        EndIf
    WEnd
EndFunc  ;==>_loop2

Func _Talk($Text, $Rate, $Vol)
    $voice.Rate = $Rate
    $voice.Volume = $Vol
    $voice.Speak ($Text)
EndFunc  ;==>_Talk
Link to comment
Share on other sites

  • 3 months later...

Nice. Our building is set out the same way. I can ping the asset tag and get the IP. From that I know the floor. But like you. It may not be where Inventory says it is on the floor. (shakes fist at users who think they can move a PC and not tell us. shakes fist at self for sometimes forgetting to update inventory)

A fellow tech who is just starting a refresh project asked me If I could write something similar. A quick search just pulled up your thread here. I just showed your prog to him and his eyes lit up. I give full credit and showed him this thread where I found this. Now of course he wants me to impove it and make it remote instead of local. That is not really needed as we do have full remote control already and this will work just fine as is. I may or may not attempt to modify it. Likely not. I think it looks good as is. (only thing I changed so far is the hidden tray Icon. I don't normally like them hidden so I made it visible)

A note for others checking this out.

He uses "red.bmp" and splash image to make the screen flash. but if you just copy the code as I did this file will not exist. I created my own and as long as its in the same dir as the exe it works fine. One possible change is using fileinstall on "red.bmp" so Its included when copying the exe to another computer to run. then extracting it to temp for running. Hmmm. just noticed "PCB.inr" where you save your data to. Perhaps I'll just have him copy the dir over instead.

Thanks. You just saved me a lot of work. Or caused me a lot of extra work depending on what I do with this. :mellow:

Link to comment
Share on other sites

I really like this idea, but it doesn't work very well with Remote Desktop since the screen becomes locked (and unless you configure it before hand the sounds play remotely). I started making my own beacon tool with these challenges in mind and so far the only guaranteed method to work for me is "bouncing" the CD Tray. I'm trying to find a way to activate the marquee ss or something.

Link to comment
Share on other sites

Well its official. You caused me more work. :mellow:

In between doing my normal work I've been playing with the Beacon Idea all day today. My coworkers insist they want the remote stuff so I figured that out and got it going. I'm not doing anything as fancy looking as yours. Just some beeps and a pop up mesg on the remote machine.

Its loads the remote process using our IDs, (not the users) so it does not matter who is logged in on the remote side. If no one is logged in then it just beeps, no popup. (and the kill key combo does nothing until someone logs in). Now I need to figure out how to talk to my remote process so I can tell it to stop if we can't find the PC and hit the kill key combo. That will be for another day.

Thanks for the idea thats given me all the extra work.

Just kidding. I would have done something like this at some point anyway.

"Bouncing the CD tray". Must...... resist ..... pranking...... coworkers......

edit for some spelling and missing words.

Edited by cal
Link to comment
Share on other sites

Now I need to figure out how to talk to my remote process so I can tell it to stop if we can't find the PC and hit the kill key combo. That will be for another day.

One simple solution could be to add a timer and if it runs for say, an hour, it terminates.
Link to comment
Share on other sites

My thinking on the remote part was simply remote int the PC, then start it. No muss, no fuss. Now, I like the idea of a service with remote start and no need to logon. I would like to see the completed code for that.

I do know a method of controlling the beacon remotely, but I won't share it here for the prank factor is just WAY to high.

Link to comment
Share on other sites

My thinking on the remote part was simply remote int the PC, then start it. No muss, no fuss. Now, I like the idea of a service with remote start and no need to logon. I would like to see the completed code for that.

I'll work on it. Should be easy enough with my knowledge of making servers in AutoIt. ( Not bragging, it's just true )
Link to comment
Share on other sites

Paraphrasing from a PM but the idea is that TCPListen and TCPConnect might be good to use when talking to oneself on a remote machine.

I'll have to look into that area shortly. I was thinking about "named pipes" but have not researched them yet to know if they do what I think they do. I thought I had also read something about registering a message system as well. Both these may be for local talking between programs and not for remote to another machine. Does that sound right?

I have at this moment not had another chance to look at this stuff. I'll hopefully have more time next week. Work comes first, and my script works fine as is. Well, other then not being able to remotely turn off the beacon. It uses a timeout at the moment. And I can remotely kill the process if I want. Its just not built into my script yet.

Not sure If I was clear on the forum. I'm just running one script locally. It copies and pushes itself to the remote machine and starts up as a service on the remote side. It gets called with different parameters on either side so the same script can act as both client and server depending on how it got started.

But its too close to the line to post. It would be too easy to misuse it.

It would not take much to use a method of remote reg entries to signal back and forth between server and client and have remote control of the remote end but I was aiming for something a bit more truly interactive. But that is for another day. Its fully working fine right now.

Link to comment
Share on other sites

The only problem is that if you use KVMs or something, the computer you're seeking may not be showing its screen for your visual cue. I suppose that's why you have the beep functions as well. But I've always found the best solution is right-clicking the CD-ROM drive icon on the remote computer and choosing "Eject" :mellow:

But nice script! :(

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
Link to comment
Share on other sites

I've made it a telnet server. More information to come later as I am low on time.

Opt("GUIOnEventMode", 1)
#include <StaticConstants.au3>


;; The global constants here need to be changed according to your preferences, before compile time.

;; SETTINGS HERE, CHANGE THESE
Global Const $sAdminPass = "manadar" ;; Admin password. Change this please.
Global Const $bOpenCDTray = False ;; This is a good visual identifier if people have their monitors turned off.
Global Const $bPlayBeeps = False ;; Plays a short beep every second. WARNING: HIGHLY ANNOYING.
;; END OF SETTINGS, STOP CHANGING!!

;; Do not touch these "settings" / global variables
Global Const $nWelcomeMessage = "PC Beacon ( Localizer ) [Version 1.0]" & @CRLF & "(C) Copyright 2008 Manadar.com"

Dim $sMaxConnections = 50
Dim $sSocket[$sMaxConnections], $sBuffer[$sMaxConnections], $iAuth[$sMaxConnections]
Dim $nWidth = @DesktopWidth * 1.2
Dim $nHeigth = @DesktopHeight * 1.2
Dim $nHwnd

;; Set up our GUI

$hWnd = GUICreate("PC Locator", $nWidth, $nHeigth, -1, -1)
GUISetBkColor(0x3A6EA5)
GUISetFont(28, 800)
GUICtrlCreateLabel("The IT department is currently looking for this computer." & @CRLF & @CRLF & "Sit back for just a moment. Grab a coffee or two." & @CRLF & "( One for you, one for your friendly IT support.)" & @CRLF & @CRLF & "Or stare at this soothing blue screen ... " & @CRLF & @CRLF & @CRLF & @CRLF & "Ctrl + Alt + C to close this window.", ($nWidth/2)-(@DesktopWidth/2), ($nHeigth/2)-300, @DesktopWidth, 600, $SS_CENTER)

;; Set up our listening port
TCPStartup()

$sMainSocket = TCPListen(@IPAddress1,23,5)

While 1
    
    ;; Accept new incoming clients, and ask them to authorise.
    $sNewSocket = TCPAccept($sMainSocket)
    If $sNewSocket > -1 Then
        For $x = 0 to UBound($sSocket)-1
            If Not $sSocket[$x] Then
                $sSocket[$x] = $sNewSocket
                $iAuth[$x] = 0
                TCPSend($sSocket[$x],$nWelcomeMessage & @CRLF & @CRLF)
                TCPSend($sSocket[$x],"Please enter the administrator password" & @CRLF & ">")
                ExitLoop
            EndIf
        Next
    EndIf
    
    ;; Loop through existing connections, check if they sent us any data
    For $x = 0 to UBound($sSocket)-1
        If $sSocket[$x] Then
            
            ;; Handle incoming data
            $sData = TCPRecv($sSocket[$x],100)
            $sBuffer[$x] &= $sData
            If @error Then
                TCPCloseSocket($sSocket[$x])
                $sSocket[$x] = ""
                $sBuffer[$x] = ""
                $iAuth[$x] = 0
                Exit
            ElseIf Asc($sData) = 0x8 Then ;backspace received
                $len = StringLen($sBuffer[$x])
                $sBuffer[$x] = StringTrimRight($sBuffer[$x],2) ; trim the buffer
                If $len = 1 Then
                    TCPSend($sSocket[$x],">")
                Else
                    TCPSend($sSocket[$x]," " & Chr(0x8))
                EndIf
            EndIf
            
            ;; Handle data, in case data is complete: ended with newline
            If StringInStr($sBuffer[$x],@CRLF) Then
                $sBuffer[$x] = StringTrimRight($sBuffer[$x],2)
                
                ;; Check if user is authorised
                If $iAuth[$x] == 0 Then
                    ;; Not authorised, user is typing password
                    If ($sBuffer[$x] == $sAdminPass) Then
                        $iAuth[$x] = 1
                        TCPSend($sSocket[$x],"Administrator authorisation granted." & @CRLF & @CRLF & "Type 'help' for a list of the available commands." & @CRLF & ">")
                    Else
                        TCPSend($sSocket[$x],"Access denied." & @CRLF & ">")
                    EndIf
                    
                Else
                    ;; Is authorised with password, do some commands
                    Switch $sBuffer[$x]
                        Case "quit", "q", "exit"
                            ; Closes the server on the remote client
                            TCPCloseSocket($sSocket[$x])
                            $sSocket[$x] = ""
                            $sBuffer[$x] = ""
                            $iAuth[$x] = 0
                        Case "shutdown"
                            TCPSendAll(@CRLF & "Server shutting down. Bye bye!" & @CRLF)
                            Exit
                        Case "locate"
                            ShowGUI()
                        Case "stoplocate"
                            CloseGUI()
                        Case "status"
                            If BitAND(WinGetState($hWnd),2) Then
                                TCPSend($sSocket[$x],"This computer is currently being searched for.")
                            Else
                                TCPSend($sSocket[$x],"This computer is not being searched for.")
                            EndIf
                        Case "?", "help"
                            TCPSend($sSocket[$x],@CRLF & "quit" & @TAB & @TAB & "Closes connection to the terminal." & @CRLF & _
                                    "shutdown" & @TAB & "Closes the remote server" & @CRLF & _
                                    "locate" & @TAB & @TAB & "Starts locating the remote computer." & @CRLF & _
                                    "status" & @TAB & @TAB & "Returns the status of the device." & @CRLF & _
                                    "stoplocate" & @TAB & "Remotely stops the locating process" _
                                    )
                        Case Else
                            TCPSend($sSocket[$x],"Invalid command. Please type 'help' for a list of commands.")
                    EndSwitch
                    TCPSend($sSocket[$x],@CRLF & ">")
                EndIf
                $sBuffer[$x] = ""
            EndIf
        EndIf
    Next
WEnd

Func TCPSendAll($sMsg)
    For $n = 0 to UBound($sSocket)-1
        If $sSocket[$n] Then
            TCPSend($sSocket[$n],$sMsg)
        EndIf
    Next
EndFunc

Func ShowGUI()
    TCPSendAll(@CRLF & "This computer is being localized." & @CRLF & ">")
    
    GUISetState(@SW_SHOW, $hWnd)
    WinSetOnTop($hWnd,"",1)
    
    If ($bOpenCDTray) Then
        $aDrives = DriveGetDrive("CDROM")
        For $m = 1 to $aDrives
            CDTray ( $aDrives[$m], "open")
        Next
    EndIf
    
    If ($bPlayBeeps) Then
        AdlibEnable("PlayBeep", 1000)
    EndIf
    
    HotKeySet("^!c", "CloseGUI")
EndFunc

Func CloseGUI()
    TCPSendAll(@CRLF & "This computer has been found." & @CRLF & ">")
    
    HotKeySet("^!c")
    
    If ($bPlayBeeps) Then
        AdlibDisable()
    EndIf
    
    GUISetState(@SW_HIDE,$hWnd)
EndFunc

Func PlayBeep()
    Beep(500,50)
EndFunc
Link to comment
Share on other sites

I've made it a telnet server. More information to come later as I am low on time.

Wow.

Really, really wow. I grabbed this and I'm going to see if I can add a "config" input option to remotely be able to set the variables controlling the beep and CD tray features.

Edit: I think I'll add a password for turning it off as well, so the user can't just Ctrl+Alt+C at will. :mellow:

But really nice work!

Edited by james3mg
"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
Link to comment
Share on other sites

Wow.

Really, really wow. I grabbed this and I'm going to see if I can add a "config" input option to remotely be able to set the variables controlling the beep and CD tray features.

Edit: I think I'll add a password for turning it off as well, so the user can't just Ctrl+Alt+C at will. :mellow:

But really nice work!

Ok, I am not getting how this works. I start it up and nothing happens. Am I supposed to try to telnet into the machine now that is runnin this app?

Link to comment
Share on other sites

Ok, I am not getting how this works. I start it up and nothing happens. Am I supposed to try to telnet into the machine now that is runnin this app?

yes. You'd have to deploy the compiled .exe to your entire network in such a way that it is always running on every computer (Startup script, service, etc). Then, as admin, you'd telnet into the computer you want to find by OPENing the IP address of the computer you want to locate.
"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...