Sign in to follow this  
Followers 0
Kip

Check if someone runs a program?

22 posts in this topic

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

Share this post


Link to post
Share on other sites



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 ?


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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]

Share this post


Link to post
Share on other sites

thnx, man!

shift alt D will stop it from running (until its opened again)

also, that script only closes the window, it doesnt close MSN 100% it is still in the task bar


[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]

Share this post


Link to post
Share on other sites

He, we gaan geen "zustertje pesten" ...toch ? :)

nee, maarja. de vorige keer was haar computer na 10 dagen alweer 1 grote troep. dus.. als ze het niet alleen af kan.....

Share this post


Link to post
Share on other sites

nee, maarja. de vorige keer was haar computer na 10 dagen alweer 1 grote troep. dus.. als ze het niet alleen af kan.....

I am confused :) german?


[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]

Share this post


Link to post
Share on other sites

shift alt D will stop it from running (until its opened again)

also, that script only closes the window, it doesnt close MSN 100% it is still in the task bar

but you can replace WinClose() with ProcessClose("msnmsgr.exe")

I am confused :) german?

nope, Dutch

Share this post


Link to post
Share on other sites

but you can replace WinClose() with ProcessClose("msnmsgr.exe")

I like your thinking lol


[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]

Share this post


Link to post
Share on other sites

Why not:

If fileexists (mysister's program) then
filedelete(mysister's program)
endif

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

Why not:

If fileexists (mysister's program) then
filedelete(mysister's program)
endif
incase its in the common program files, its easier to just close it,

[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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!"

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

#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

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