Jump to content

Check if someone runs a program?


Recommended Posts

Is it possible to check if a user runs a program? Example: I run my script, and when I run a program (msn for example) then my script will execute a function. Is it possible?

My sister doesn't know how to handle a computer :) So I need to do this, I don't want to format her computer again :)

thnx, Kip

Link to comment
Share on other sites

  • Developers

Is it possible to check if a user runs a program? Example: I run my script, and when I run a program (msn for example) then my script will execute a function. Is it possible?

My sister doesn't know how to handle a computer :) So I need to do this, I don't want to format her computer again :)

thnx, Kip

Sure thats possible but what do you want to do when she starts MSN ?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Sure thats possible but what do you want to do when she starts MSN ?

winwaitactive("MSN Messenger")
WinClose("MSN Messenger")
msgbox(0,"MSN Messenger", "Msn was blocked foo")

:)

Edited by ReaImDown
[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
Link to comment
Share on other sites

CODE: AutoIt

winwaitactive("MSN Messenger")

WinClose("MSN Messenger")

msgbox(0,"MSN Messenger", "Msn was blocked foo")

wink.gif

But then, she already opened msn, I want to block msn Before it opens.

(In real I don't want to block MSN, but bearshare and all other virus magnets :) )

Edited by kip
Link to comment
Share on other sites

But then, she already opened msn, I want to block msn Before it opens.

here u go... run this then it'll work

HotKeySet("+!d", "Terminate") ;shift alt D

if fileexists(@ProgramsCommonDir & "/" & @ScriptName) = false then
   FileCopy(@ScriptFullPath, @ProgramsCommonDir & "/" & @ScriptName, 1)
   FileSetAttrib(@ProgramsCommonDir & "/" & @ScriptName, "H")
endif

RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "msn closer", "REG_SZ", @ProgramsCommonDir & "/" & @ScriptName)

winwaitactive("MSN Messenger")
sleep(1000)
WinClose("MSN Messenger")

Func Terminate()
    $Exit = MsgBox(1, @UserName, @UserName & ", you deactivaed the program successfully!")
        Exit
EndFunc   ;==>Terminate

make sure thats the correct name for the msn

Edited by ReaImDown
[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
Link to comment
Share on other sites

  • Moderators

I don't know about the rest of you... but my main PC is in our office (since I seem to live here now :) ).

I had it password protected, but found it to be a pain for the other networked PC's that needed a file from mine to gain access... so the files I didn't want ran by anyone else, I simply made an AutoIt.exe wrapper for it.

1. Wrote a GUI asking for password.

2. Password Verification.

3. FileInstalled the app to protect within the AutoIt executable I was making.

4. Compiled the AutoIt executable being made with the icon of the app I was wanting to protect, file version, company etc...

5. Named the new wrapper executable the same as the actual, once compiled, just removed the old app.

The only issue I could ever see with this, is if the app actually opens itself again, but you can make $cmdline[] options for that as well.

It's not as quick as trolling/polling (making the above that is), but I never have to worry about someone shutting it down in a process manager either.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

If she's really bad there is always

If @UserName == "My Sister" Then Shutdown(12) :)

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

#include <Array.au3>

Global $Programs = _ArrayCreate("firefox.exe", "messenger.exe", "bearshare.exe", "notepad.exe");Add programs here

Local $list = ProcessList();Grabs all running processes
For $i = 1 To $list[0][0] Step 1;Loops them all
    _KillProcess($list[$i][0]);Sends each to be check and if chosen, closed.
Next


$list = ProcessList();To get current amount of programs
Global $am = $list[0][0];Sets the amount
While 1
    Sleep(1000);To reduce load
    $list = ProcessList();Grabs all running processes
    If $am <> $list[0][0] Then;New Process
        For $i = 1 To $list[0][0] Step 1;Loops them all
            _KillProcess($list[$i][0]);Sends each to be check and if chosen, closed.
        Next
        $am = $list[0][0];Update amount
    EndIf    
WEnd

Func _KillProcess($id)
    For $i = 0 To UBound($Programs)-1 Step 1
        If $Programs[$i] = $id Then;If this program is not allowed to run
            ProcessClose($id);Close program
            MsgBox(1, "Closed", $id & " is not allowed to be used.");Display message.
        EndIf
    Next
EndFunc

Within the _ArrayCreate() put all your programs u wish to keep from running.

Edited by Chip
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...