Sign in to follow this  
Followers 0
myspacee

Watchdog

4 posts in this topic

#1 ·  Posted (edited)

Watchdog program,

sure exist but make my own. muttley

first run, make list of your 'safe' program (.exe)

second run, monitor running .exe and kill if not in list

Shift + Alt + d to exit

: edited :

Use sysinternal pskill to kill process, copy pskill.exe to you c:\ if compile.

download it from microsoft

;////////////////////////////////////////////////////////////////////
;//   Watchdog  - kill not allowed programs
;////////////////////////////////////////////////////////////////////
#NoTrayIcon
HotKeySet("+!d", "Terminate");Shift-Alt-d
;////////////////////////////////////////////////////////////////////
;//   ONLY ONE SESSION AT TIME
;////////////////////////////////////////////////////////////////////
$list = ProcessList(@ScriptName)
for $i = 1 to $list[0][0]
    if $i > 1 Then
        msgbox(0, "Alert!", "Only one instance is allowed : " & @ScriptName, 1)
        ProcessClose($list[$i][1])
    EndIf
next
;//////////////////////////////////////////////////////////////////////
;//   copy Sysinternal pskill in working directory
;//////////////////////////////////////////////////////////////////////
If FileExists(@WorkingDir & "\pskill.exe") Then
;do nothing
Else
    FileInstall("c:\pskill.exe", @WorkingDir & "\pskill.exe", 1)
EndIf
    

;//////////////////////////////////////////////////////////////////////
;//   MAIN
;//////////////////////////////////////////////////////////////////////

if FileExists("allowed.ini") then ;if .ini exists kill other process
    While 1
        XenoKiller()
        sleep(1000)
    WEnd
else
    StoreRunning()              ;if .ini NOT exists create file/list 
EndIf




;//////////////////////////////////////////////////////////////////////
;//   FUNCTIONS
;//////////////////////////////////////////////////////////////////////
;//   FIRST RUN create allowed .exe list
;//////////////////////////////////////////////////////////////////////
Func StoreRunning($file = "allowed.ini")
; List all processes in a File
    local $list = ProcessList()
    
    for $i = 1 to $list[0][0]
        FileWriteLine("allowed.ini", $list[$i][0] & @CRLF)
    next
    msgbox(0, "First Run", "OK, i've created allowed.ini that contains allowed .exe." & @CRLF & "Remember ! SHIFT+Alt+d to quit " & @ScriptName)
EndFunc

;/////////////////////////////////////////////////////////////
;//   KILL process not in list
;/////////////////////////////////////////////////////////////
Func XenoKiller()
; List all processes
    local $list = ProcessList()

;/////////////////////////////////////////////////////////////
;//   FOR to find running .exe in my list
;/////////////////////////////////////////////////////////////
    for $i = 1 to $list[0][0]
        Local $linenum = 0              ;This is for skip line in filereadline function
        $file = FileOpen("allowed.ini", 0);open allowed list
        If $file = -1 Then              ; Check if file opened for reading OK
            MsgBox(0, "Error", "Unable to open file.")
            Exit
        EndIf
;/////////////////////////////////////////////////////////////
;//   PROCESS = line read  ?
;/////////////////////////////////////////////////////////////
        While 1
            $linenum = $linenum + 1                                                             ;add one to skip next line
            $line = FileReadLine($file, $linenum)                                               ;each cicle read next line
            if $list[$i][0] = $line Then ExitLoop                                               ;if process name is in my list it's safe, exit to next one
            If @error = -1 Then                                                                 ;if EOF , I can't find in my list
                Run(@ComSpec & " /c " & "pskill -t " & $list[$i][0], "", @SW_HIDE) ;kill him
                ExitLoop                                                                        ;and exit to next one
            EndIf
        Wend
        FileClose($file)
    next
EndFunc

Func Terminate()
    ToolTip("ok, quit " & @ScriptName, 0, 0)
    Sleep(2000)
    Beep(500,250)
    Beep(1000,250)
    Beep(500,250)
    Exit 0
EndFunc

thank you all for your time,

m.

Edited by myspacee

Share this post


Link to post
Share on other sites



Watchdog program,

Shit + Alt + d to exit

Is that like pressing the flush button? muttley

Share this post


Link to post
Share on other sites

hello Confuzzled,

if for 'flush' button you mean toilet button you make me smile muttley

change it if you don't like, you have source....

m.

Share this post


Link to post
Share on other sites

He was talking about your typo. Look at his quote closely. muttley

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
Sign in to follow this  
Followers 0