Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

RUN program that monitors if process exit


  • Please log in to reply
11 replies to this topic
rockeveryone21
  • Members
  • 13 posts
  • Last active: Aug 31 2008 03:16 AM
  • Joined: 06 Aug 2008
hey can you guys help me out i,m working on a project
here it goes :

do you know how to make a program that will run silently and will monitor is two processes are running or not

if process a is running than it will launch process b
but if pocess a exits than it kills process a

i,ll call the program
monitor.exe
it does
if notepad.exe is running
then run notepadhelper.exe
if notepad.exe terminates
then terminate notepadhelper.exe

the program has no taskbar icon or options

i would really really be thankfull if someone would be kind enough to show me what the code would look like ,i realy need this

Serenity
  • Members
  • 1271 posts
  • Last active:
  • Joined: 07 Nov 2004
Instead of polling for active processes, you could achieve something similar with the RunWait command:

run, notepadhelper.exe 
runwait, notepad.exe
process, close, notepadhelper.exe


Sivvy
  • Members
  • 726 posts
  • Last active: Apr 23 2010 02:50 PM
  • Joined: 21 Jul 2008
#NoTrayIcon
Process, Wait, notepad.exe
Run, Path\NotePadHelper.exe
Process, WaitClose, notepad.exe
Process, Close, notepadhelper.exe

Change the names to suit your needs. I doubt notepadhelper is right.

poo_noo
  • Members
  • 251 posts
  • Last active: Dec 02 2014 10:32 PM
  • Joined: 08 Dec 2006
Below is some timer code that I have that checks for a RDP or Citrix connection.

If a RDP or Citrix connection is detected, it kills AutoHotkey.exe. If no connection, then it starts AutoHotkey.exe.

;#############  Below is the auto-executing & persistent code ######################################

#NoEnv						; Recommended for performance and compatibility with future AutoHotkey releases.Avoids checking empty variables to see if they are environment variables.
SendMode Input				; Recommended for new scripts due to its superior speed and reliability.
#persistent
#SingleInstance force
SetTitleMatchMode, 2
#MaxMem 2
#InstallKeybdHook
#NoTrayIcon
DetectHiddenWindows On 

; do initial sleep on start up to allow normal autohotkey startup at operator logon
Sleep, 20000

;############# Set timer for Process checker ######################################################

SetTimer, processchecker, 100

; Disable the right click menu for tray icon so IDT operators cannot close the AHK programme
	{
	Menu, Tray, NoStandard 
	Menu, Tray, DeleteAll
	}

;############# below is the timer for Process checker ############################################

processchecker:
Process, Exist, wfica32.exe 	; check to see if Citrix Client (wfica32.exe) is running. If running, kill AutoHotkey.exe on the host PC as it interferes with CITRIX
	citrix_pid=%errorLevel%			; errorlevel equals the PID if active
Process, Exist, mstsc.exe		; check to see if Microsoft (mstsc.exe) is running. If running, kill AutoHotkey.exe on the host PC
	remotedesktop_pid=%errorLevel%	; errorlevel equals the PID if active
If (citrix_pid + remotedesktop_pid = 0)
		{
			; neither client is present so check for AutoHotkey.exe
			Process, Exist, AutoHotkey.exe ; check to see if AutoHotkey.exe is running
			{
			If ! errorLevel
				{
				Run,%A_ProgramFiles%\AutoHotkey\AutoHotkey.exe
				Return
				}
			else
				{
				Return
				}
			}		
		}
	else
		; one or more client is present so close AutoHotkey.exe
		{
		Process, Close, AutoHotkey.exe
		Return
		}
Return


You might be able to adapt it to suit your needs.

rockeveryone21
  • Members
  • 13 posts
  • Last active: Aug 31 2008 03:16 AM
  • Joined: 06 Aug 2008
thanks mate for all your help everyone who posted

i have another question
can you tell me the syntax to do this:

copy cowscanfly.txt from c:\dogs
to c:\cows
rename cowscanfly.txt in c:\cows to cowscansing.exe
Process, WaitClose, notepad.exe
Process, Close, cowscansing.exe
delete cowscansing.exe

Serenity
  • Members
  • 1271 posts
  • Last active:
  • Joined: 07 Nov 2004
See FileCopy, FileDelete, and FileMove for renaming and moving files.

Sivvy
  • Members
  • 726 posts
  • Last active: Apr 23 2010 02:50 PM
  • Joined: 21 Jul 2008
Just curious, what do you plan to do with this?

Just sitting back and looking, it seems almost like the right strategy for a Keylogger to attach (Silently) to a program, record info, and hide its evidence...

Not that you'd be thinking that... :shock:

rockeveryone21
  • Members
  • 13 posts
  • Last active: Aug 31 2008 03:16 AM
  • Joined: 06 Aug 2008
no nah its nothing of that sought i,m making it as a protection system form my program see i,ll create a main exe and rename it to something else and put in dummy files in the same directory etc etc if youll search all my posts are related so no probs i,m a good man

i,m just having problem reading and understanding the text eventually ill get through but i have so little time to do stuff

rockeveryone214
  • Guests
  • Last active:
  • Joined: --
hey how do you make a dependency example
lets say i make a program named tuna.exe i want it to have a dependency if the dependency is not found the tuna exe does not run
if cows.exe exists than

Sivvy
  • Members
  • 726 posts
  • Last active: Apr 23 2010 02:50 PM
  • Joined: 21 Jul 2008
You mean to check if a file exists, and if not, don't run?

rocky256
  • Guests
  • Last active:
  • Joined: --
yes if a process exits than contineu running but if it doesnt than dont run

Sivvy
  • Members
  • 726 posts
  • Last active: Apr 23 2010 02:50 PM
  • Joined: 21 Jul 2008
Look at IfExist. That should do it for you. Or for a process, Look at Process.

Process, Exist, %PID%